The road to NS3---code Editor vim

Source: Internet
Author: User

Before the development of NS3, the first thing we need is the editor, in addition to the original VI, VIM as the enhanced version of VI, is the first choice, the second can consider gedit. This article has selected vim.

In the higher version of Ubuntu, Vim is generally installed. Then the use of Vim is described below:

Vi/vim Mode Introduction

There are three modes in the Linux vi/vim Text Editor: command mode , input mode and last line mode . What is the difference between the three models?

The command mode is the default mode after the Vi/vim editor enters, from the command mode can be switched to the input mode and the last line mode, if you enter the other two modes, you can use the "ESC" key to return to the command mode. In the command mode, you can enter some commands specific to the text editor, such as if you want to edit the file, then you need to enter "I" to make the current mode into insert mode or input mode, so you can edit the text.

The input mode is the name of the input to this article, which means you can make changes to the file. Otherwise, in command mode, the Vi/vim text editor is read-only and you cannot make changes to the text.

The last line mode is the command mode input ":", when you in the input mode, the file changes, you need to go back to the command command, then enter the last line mode, and enter "Wq", you can save and exit the Vi/vim text editor. If you want to not save the exit Vi/vim text editor, then enter "q!" directly.

Running the Vi/vim text editor under Linux systems

Under the Linux command line, enter the VI or VIM command:






Linux common commands for the next Vim/vi text editor
#1 commands to enter the Vi/vim text editor
VI FileName: Opens or creates a new file and places the cursor at the beginning of the first line
VI +n FileName: Open the file and place the cursor in the position of the nth row
VI + FileName: Opens the file and places the cursor at the last line
VI +/pattern FileName: Opens the file and places the cursor at the beginning of the first match to pattern
Vi-r FileName: The last time the Vim text editor was requisitioned, a system crash occurred, restoring the filename file
VI filename1...filenamen:linux vi/vim Text Editor can be edited by opening multiple files

#2 Linux Vi/vim commands for moving the cursor under a text editor
H: Move the cursor to the top line of the screen
M: Move the cursor to the middle line of the screen
L: The cursor moves to the last line of the screen
0: Cursor moves to the beginning of the current line
$: Cursor moves to the end of the current line

#3 Linux Vi/vim Text Editor screen tumbling class command
Ctrl+f: Turn the whole page forward
Ctrl+u: Turn half a page forward
Ctrl+b: Turn Back Full page
Ctrl+d: Turn back Half page

#4 Linux Vi/vim Text Editor insert text Class command
I: Before the cursor
I: At the beginning of the current line
A: After the cursor
A: At the end of the current line
O: A new line below the current line
O: Start a new line before the current row

#5 Linux Vi/vim Text Editor Delete command
Do: Delete to the beginning of the line
d$: Delete to end of line
DD: Delete cursor in the row
NDD: Delete current navigation and its subsequent n-1 lines
D: Delete the current cursor to the end of the line content
Ctrl+u: Delete all text entered under input mode

#6 Linux Vi/vim Text Editor search and replace commands
/pattern: Search pattern mode from the beginning of the cursor at the end of the file
? pattern: Searches for pattern mode from the beginning of the cursor to the top of the file
: s/p1/p2/g: Replaces all P1 in the current row with P2
: n1,n2s/p1/p2/g: Replace all P1 in line N1 to N2 with P2
: g/p1/s//p2/g: Replace all P1 in the file with P2

#7 Linux Vi/vim text Editor copy and paste commands
In the Vi/vim text editor "Y" means copy, "D" means delete, "p" means paste, usually used in conjunction with the cursor Movement command
Y$: Represents the copy of the content from the current cursor to the end of the line
d$: Indicates the deletion of content from the current cursor to the end of the line
YY: Indicates that the copy cursor is in the row

#8 Linux Vi/vim Text editor undo action Command
U: Cancel the last operation
U: Cancel All operations

#9 Vi/vim commands in the editor's last-line mode
N1,n2 d: Delete the contents of N1 rows to N2 rows
: W Save current file
: E filename Opens file filename for editing
: x saves the current file and launches
: Q Exit Vi/vim Editor
: q! Do not save and exit the Vi/vim editor

These are the most commonly used command sets in the Vi/vim text editor under Linux. For more information on the use of the Vi/vim editor, refer to the official Help documentation.

The road to NS3---code Editor vim

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.