Vim usage tips (common directives)

Source: Internet
Author: User

1. Vim Base operation

Vim is a text editor developed from VI. Code completion, compilation and error jumps have done some enhancements

1.1 Entering edit mode
Command meaning
I and I I insert before the cursor, I insert at the beginning of the line.
A and a A is inserted after the cursor, and a is inserted at the end.
O and O o Insert the row below the line where the cursor is located, and O insert a row on the line where the cursor is located.

1.2 Entering command mode

ESC: Enter command mode from insert mode or last line mode

1.3 Moving the cursor
Command meaning
H Move cursor to the left
J Move Cursor Down
K Move Cursor up
L Move the cursor to the right
H, M, L The cursor moves to the first line of the visible screen (H), the middle row (M), and the last row (L)
^ and$ ^ Move to the beginning of the $ line, move to the end
G and GG G Document last line, GG document first row
Ctrl+f, Ctrl+b Flip the screen forward and flip the screen backwards
Ctrl+d, Ctrl+u Forward half graphic, back half graphic
and {Move up a paragraph,} move backward by a paragraph
W and b W Move one word forward and B to move one word backwards
1.4 Delete Command
Command meaning
X and X X Delete a character after the cursor, x delete the previous character of the cursor, including the cursor position character
DD and N DD DD Delete Row, 5 dd Delete the specified number of rows
D0 and D D0 Delete all contents before the cursor, d Delete all contents of the line after the cursor, including the cursor position character
Dw Delete the word where the cursor is located, including the position character of the light Table
1.5 Undo Command
Command meaning
U One-step, one-step undo
CTRL + R Anti-revocation
1.6 Repeating commands
Command meaning
. Commands that repeat the last action
1.7 Move Command
Command meaning
>> Text lines Move Right
<< Line of text moves left
1.8 Copy and paste:
Command meaning
YY, n yy, y$ y^ yy Copy the current line, 5 yy copy 5 lines
P Paste a new line down the cursor position
1.9 Find Replacements:
Command meaning
Command mode, R and R R replaces the current character, R replaces the character after the cursor
In the last row mode,/+ str n Find Next, n Find Previous
In the last line mode, the%s/abc/123/g Replace all ABC in the file with 123
Last-line mode, 1, 10s/abc/123/g Replace the ABC between the first line and the 10th line with 123
Note: The shell command is executed in VIM: 末行模式里输入!,后面跟命令

Vim usage tips (common directives)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.