1.Vim is an advanced version of the Vi,vim can not only display text content in different colors, but also can do such as Shell Script,c program editing functions.
The difference: VI is the teacher's word processor, but the function is very complete, but there is still a place to progress.
Vim is a "program development tool" rather than a word processing software. On the basis of VI, we add a search framework that supports regular expressions, multi-file editing, chunk copying, and so on.
2, VI has the general mode, the editing mode, and the command column commands the mode.
General mode: You can move the cursor up or down, or you can use delete character and delete entire line, copy and paste to process your file, but you cannot edit the file.
Edit mode: In general mode, press "I,i,o,o,a,a,r,r (replace)" After any one of the letters will not enter the editing mode. If you want to go back to normal mode, you can exit edit mode by pressing the ESC key.
Instruction column Command mode: In general mode, type ":/?" You can move the cursor to the bottom row by any one of the three buttons. In this mode, you can provide "search data, read, save, a large number of substitution characters, leave VI, display line number" and other actions
VI must be added after the file name: VI test.txt. Enter document editing mode
Leave character command ": Wq"
Ls-l: Viewing file properties
Normal mode: H (left) J (bottom) K (UP) L (right) move the cursor, if you want to make multiple moves, move down 30 lines can use "30j" or ""
"Ctrl+f" = "Page Down"
"Ctrl+b" = "Page Up"
"Ctrl+d": Move Down half page
"Ctrl+u": Move Up half page
20<SPACE>: The cursor moves back 20 character distances
/word: Look under the cursor for a string called word, such as in the file to find Vbird this string, enter/vbird can
? Word: Look for a string called word on top of the cursor, such as searching for Vbird in the file, enter/vbird to
N: Represents the action of repeating the previous search. N: Just the opposite of N, the previous search action is reversed.
Note: Using/word, with N and N is very helpful, so you quickly find keywords
: n1,n2s/word1/word2/g: N1 and N2 are numbers. In section N1 and N2, look for the string word1, and replace the string with Word2! For example, between 100 and 200, the vbird is searched and replaced by the Vbird: ": 100,200s/vbird/vbird/g". Common
: 1, $s/word1/word2/g: look for the word1 string from the first line to the last line, and replace the string with Word2! Common
: 1, $s/word1/word2/gc: look for the word1 string from the first line to the last line, and replace the string with Word2! and display the prompt character before the substitution to the user to confirm (confirm) whether need to replace! Common
X,x: In a line of words, X is the backward deletion of a character, X is a character to be deleted forward
Nx:n is a number that continuously deletes n characters backwards.
P,p:p the copied data is pasted on the next line of the cursor, and P is the last line attached to the cursor.
U: Restores the previous action.
Ctrl+r: Redo a previous action
Edit mode:
I,i:i to insert from the current cursor location, I begins the insertion at the first non-whitespace space currently in the row
A,a:a the insertion begins at the next character where the cursor is currently located, a is inserted at the last character of the line where the cursor is located
Instruction-Column mode:
! : In VI, often have the meaning of coercion
ZZ: Uppercase Z, if the file has not changed, do not store away, if the file has been changed, then the store left.
: W[filename]: Save edited data to another file
: R[filename]: In the edited data, read the data from another file. [FileName] This file is appended to the line where the cursor is located.
: N1,n2 W[filename]: Store N1 to N2 content as filename this file
: Set Nu: Display line number
: Set Nonu: Cancel line number
Tenth chapter VIM Program Editor Learning