This article extracts from:
http://www.linuxsir.org/main/?q=node/206
Under Linux, you can type the Vimtutor command with a vim tutorial that includes the actual operation.
The VI editor has three modes of operation: Command mode, input mode, and ex escape mode. You can convert between these three modes of work by the appropriate command or operation.
Command mode
At the shell prompt, enter command VI, enter the VI editor, and be in the command mode of VI. At this point, any characters entered from the keyboard are interpreted as an edit command, for example, a (append) represents an additional command, I (insert) represents the Insert command, X is the delete character command, and so on. If the input character is not a legal command of VI, the machine emits an "alarm sound" and the cursor does not move. In addition, the character entered in the command mode (that is, the VI command) is not displayed on the screen, for example, input I, there is no change on the screen, but by executing the i command, the editor works in a different way: from the command mode to input mode.
Input Mode
The input method can be entered from the command mode by entering the VI's Insert command (i), attaching the command (a), opening the command (o), replacing the command (s), modifying the command (c), or replacing the command (R). In the input mode, all characters entered from the keyboard are inserted into the buffer being edited and are treated as the body of the file. After entering the input mode, the input visible characters are displayed on the screen, and the edit command no longer works, only as ordinary letters appear. For example, enter the letter I in the command mode, enter the input mode, and then enter I to add a letter I at the corresponding cursor on the screen. The way the input is returned to the command mode is to press the ESC key. If it is already in the command mode, then pressing the ESC key will emit a "beep" sound. In order to ensure that the user wants to execute the VI command is entered in the command mode, it is advisable to press the ESC key more than one, hear the beep and then enter the command.
ex Escape Mode
The functions of the VI and ex editors are the same, and the main difference between them is the user interface. In VI, commands are usually a single letter, such as A,x,r. In ex, the command is the command line with enter and the key to end. VI has a dedicated "escape" command to access many of the line-oriented ex commands. To use the ex escape method, you can enter a colon (:). As an ex command prompt, the colon appears in the status line (usually on the bottom line of the screen). Press the interrupt key (usually the DEL key) to terminate the command being executed. Most file management commands are executed in ex-escape mode (for example, reading a file, writing the contents of the edit buffer to a file medium). After the escape command executes, it automatically returns to the command mode.
The VI Editor's conversion between the three modes of operation.
650) this.width=650; "Src=" Http://s3.51cto.com/wyfs02/M02/88/40/wKioL1fszRvT1g4MAABhrQNYTdU436.jpg-wh_500x0-wm_3 -wmp_4-s_289855127.jpg "title=" vi.jpg "alt=" Wkiol1fszrvt1g4maabhrqnytdu436.jpg-wh_50 "/>
1. Saving and exiting Files
1.1): W save;
1.2): w filename saved as filename;
1.3): wq! Save exit;
1.4): wq! FileName Note: The filename is saved and then exited;
1.5): q! Do not save the exit;
1.6): X should be saved and exited, function and: wq! same
2. Cursor Movement
2.1) j Move down one line;
2.2) k move up one line;
2.3) h move one character to the left;
2.4) L move one character to the right;
2.5) ctrl+b Move up one screen;
2.6) ctrl+f Move down one screen;
2.7) upward arrow to move upward;
2.8) down ARROW to move down;
2.9) left Arrow moves left;
2.10) Right arrow move right;
2.11) $ move to end of line
2.12) GG move to document start
2.13) GG move to document trailer
2.14) Ctrl + F page forward
2.15) Ctrl + B page Backward
3. Insert Mode
3.1) I insert before the cursor;
3.2) A is inserted after the cursor;
3.3) I insert at the beginning of the line where the cursor is located;
3.4) A is inserted at the end of the line where the cursor is located;
3.5) O Insert a row above the line where the cursor is located;
3.6) o Insert a row below the line where the cursor is located;
3.7) s deletes a character after the cursor and then enters insert mode;
3.8) S deletes the line where the cursor is located and then enters insert mode;
4. Deletion of text content
4.1) x a character;
4.2) #x Delete several characters, #表示数字, such as 3x;
4.3) dw Deletes a word;
4.4) #dw Delete a few words, #用数字表示, such as 3DW means delete three words;
4.5) DD deletes a row;
4.6) #dd Delete more than one row, #代表数字, such as 3dd means to delete the cursor line and the next two lines of the cursor;
4.7) d$ Delete the contents of the cursor to the end of the line;
4.8) J Clears the space between the line where the cursor is located and the previous line, and the line of the cursor and the previous line are joined together;
5. Restore and restore the deletion
5.1) U undo Modify or delete operation;
6. Copying and pasting
6.1) YY Copy as Forward
6.2) #yy Copy multiple lines, #用数字表示, such as 3yy means to copy three rows;
6.3) If in visual mode, Y can copy the selected content
6.4) p Paste after the cursor
6.5) SHIFT + P is pasted before the cursor
7. Find and replace
7.1)/search Note: Forward lookup, press the N key to move the cursor to the next qualifying place;
7.2)? Search Note: Reverse lookup, press the Shift+n key to move the cursor to the next eligible
7.3): s/search/replace/g Note: Replace the search word in the row where the current cursor is in, and highlight all search;
7.4):%s/search/replace Note: Replace all the SEARCH in the document with a replace;
7.5): #,# s/search/replace/g Note: The # number indicates the number of lines to how many lines, the SEARCH is replaced with replace;
This article is from the "12112582" blog, please be sure to keep this source http://12122582.blog.51cto.com/12112582/1857807
Learning notes for Linux VI