The configuration file for vim in red Hat Linux is stored in the/directory, and the configuration file named VIMRC.G User-defined configuration can be placed in the. vimrc file of the root directory.
1. Display line numbers
Manual display: Input in vim command line mode: Set Nu
Cancel display: Input in vim command line mode: Set Nonu
Permanent Auto Display:
Vim ~/.VIMRC
Open is an empty file, we add set Nu, save exit, again into the Vim editor, will automatically show the travel number
2. Skip to the last or first line
Jump to the first line:
With the command : 0 or:1 shortcut key GG
Skip to the last line:
with the command : $ shortcut key shift+g
3. Jump to the specified line
General mode:
ngg or ng or N+entern jumps to line 25th for the specified number of rows (e.g., 25GG or 25G).
Command mode:
Enter line number in command mode
To open a file is jump:
Vim +n FileName
View the line where the current cursor is located:
In general mode, the Crl+g
4. Turning pages
[Ctrl] + [f] |
Screen "Down" to move one page, equivalent to [PAGE DOWN] key ( common) |
[Ctrl] + [b] |
Screen "Up" to move one page, equivalent to [PAGE UP] key ( common) |
5. Jump between rows 5.1 jump to the beginning of the line
0 or function key [Home] |
This is the number "0": Move to the front of the line prompt ( common) |
5.2 Jump to the end of the line
$ or Function key [End] |
Move to the last face of this line prompt ( common) |
6. Searching for strings
/word |
Look under the cursor for a string called Word. For example, in the file search Vbird This string, you can enter/vbird! ( Common) |
? word |
Look for a string with the string name word on top of the cursor. |
7. Replacing strings
: n1,n2s/word1/word2/g |
N1 and N2 are numbers. Look for the string word1 between N1 and N2, and replace the string with Word2! For example, search for vbird between 100 and 200 rows and replace it with 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) |
8. Deleting strings and rows
X, X |
In one line of words, X is the backward deletion of a character (equivalent to the [Del] key), and X is to delete a character (equivalent to [backspace], which is the backspace) ( Common) |
Nx |
N is a number that continuously deletes n characters backwards. For example, I want to delete the 10 characters consecutively, "10x". |
Dd |
Delete the entire column where the cursor is located ( Common) |
Ndd |
N is a number. Delete the down n column where the cursor is located, for example, 20DD to delete 20 columns ( common) |
d1g |
Remove all data from the first row of the cursor |
Dg |
Delete all data from the last row of the cursor |
d$ |
Delete the last character of the row where the cursor is located |
D0 |
That is 0 of the number, delete the cursor at the top of the line, and the first character |
9. Copying rows
Yy |
The row where the cursor is copied ( common) |
Nyy |
N is a number. Copy the down n column where the cursor is located, for example, 20yy to copy 20 columns ( common) |
y1g |
Copy all data from the column to the first column of the cursor |
YG |
Copy all data from the column to the last column of the cursor |
Y0 |
Copy all data from the same character as the cursor to the beginning of the line |
y$ |
Copy all data at the end of the line with the same character as the cursor |
10. Paste
P, p |
p to paste the copied data on the next line of the cursor, and p for a row on the cursor! For example, I currently have the cursor on line 20th and have copied 10 rows of data. When P is pressed, the 10 rows of data will be affixed to the original 20 lines, i.e. 21 lines. But what if we press P? Then the original 20th Guild was pushed into 30 rows. ( Common) |
Vim Usage Tips