Vim filename Edit a file
In general mode by yy is copied meaning (copy the current line), press YY before the corresponding number key is to copy the cursor line to the specified line, and then press p paste
In general mode by DD is deleted meaning (also known as cut), press DD before pressing the previous round number key is to delete the cursor line to the specified line, without the number directly press DD to delete the forward
Press R (replace) in the general mode and then the letter you want to replace to replace the letter on the current cursor.
Pressing s in the normal mode will remove the letters from the current cursor and immediately enter edit mode after deletion.
In general mode, press CTRL + V to enter the visual block mode, then you can randomly select what you want to copy, select and press Y to copy, and then move the cursor to where you want to press p to paste
In general Mode press U is undo, press Ctrl+r is forward meaning
In the general mode of VIM will display the content of the file to be edited, there is no line number in the content, if you want to add a line number can be in general mode by a colon (:) and then enter set NU will display the current line number on each line, if you want to remove the line number, enter set Nonu
According to the above method is only valid, if you want to open the file every time the display line number will be in the current user's home directory vim. VIMRC Open this file, enter set Nu, then save exit, and then use VIM to open the file will display line number
In general mode, press I or I or a or a or O or O to enter Vim's edit mode
#Replacement function
In general mode with replace function input: s/zxc/zxc/means replace zxc with ZXC (the first one found in the line where the cursor is replaced)
: s/zxc/zxc/g means replacing all matching contents of the line where the cursor is located
: 3,13s/zxc/zxc/g means replacing all matching contents from line 3rd to line 13th
:., 8s/zxc/zxc/g means to replace all matching contents of the current line to line 8th
:., $-1s/zxc/zxc/g represents the current line to the second-to-last line all matches to the contents of Replace $ represents the final line
: 1, $s/zxc/zxc/g indicates that the first line to the last line all matches to the content of the replacement
:%s/zxc/zxc/g indicates full text substitution, equivalent to the above sentence% for full text
:%s/zxc//g means to delete all matching items.
: 3,8s/^/#/g means to precede each row of line 3rd to line 8th with a # number (#号是注释) ^ for the Wardrobe
: 3,8s/^#//g means to remove the # number in front of each line from line 3rd to line 8th
In the general mode, enter: Number and then press ENTER, the cursor is located to the village of the row numbers is a digit, for example: 10, press ENTER to navigate to the 10th row
In the general mode of input/And then enter what you want to find the content you want to find, such as/ZXC press ENTER will find what you entered, press N to find the next from the top down, press N will be from the bottom to look up
After entering/finding the content, the found content will be highlighted, so it may feel uncomfortable sometimes, if you want to remove the input/then enter a longer content, and then press ENTER, then the system will be prompted to find, and then the highlight will be canceled
Enter a number in the general mode and then press the uppercase G, you can position the cursor to the line you entered, directly press G to jump to the last line, double G to jump to the first line
In general mode, press B or K to move the cursor upward, press H to move to the left, press J to move Down, press L to move to the right
Vim Common operation