To do their best, you must first sharpen your tools.
As an essential tool for Linux development, being able to maximize the effectiveness of VI will inevitably improve our work efficiency. Below are some tips for using vi.
1. Position the cursor and scroll through the screen.
Command |
Function |
$ |
End of current row |
0 |
Start of the current row |
Gg |
File Header |
G |
End of File |
10gg 10g |
Jump to row 10th |
'' |
These are two back quotes, which are the keys under ESC on the keyboard. Return to the position before the cursor jump |
H |
Jump to the first line on the screen |
M |
Jump to the middle line of the screen |
L |
Jump to the last line on the screen |
GK |
The last line on the screen |
Gj |
The next line shown on the screen |
In Vim command mode, there are many commands for moving the cursor, which brings us great convenience. The most common method is0And$To position the cursor at the beginning and end of the line.
Frequently UsedGPosition the cursor at the end of the file,GgReturn to the file header. Add a number before the two commands to go to that line, for example10ggWill take you to 10th rows.
''The function is to return to the position before the cursor jump. For example, assume that the cursor is currently in row 10th, press G to the end of the file, and then press ''to return to row 10th.
If you find thatKAndJNot very useful (just click a few lines on the screen), you can try itGKAndGj.
2. Copy, cut, and paste.
Command |
Function |
Dd |
Delete current row |
YY |
Copy current row |
D $ |
Delete content from cursor position to end of line |
Yt < |
Copy the content from the cursor position to the next "<" (In addition,CT <Modifying the content from the cursor to "<" is convenient when editing HTML and XML files) |
"X copy |
Put the copied content into Register x (X can be one of 26 English letters, case sensitive) |
"XP |
Paste the content of register x |
"+ |
Special register, read/write system clipboard |
: Reg |
View the content of each register |
D. Delete the character from the cursor to the end of the line.
Address: http://www.cnblogs.com/cocowool/archive/2009/04/15/1436619.html