Vim usage record

Source: Internet
Author: User

Automatic indent settings: Set cindent

Format and adjust. =

Manual adjustment. <And>

Code auto-completion

Insert mode: C + n to complete the next step; C + P to complete the previous step.

Show row number

Command mode: set number

Powerful g commands

Http://blog.sina.com.cn/s/blog_6e128365010153no.html

Search
In command mode, enter/Word and press enter to search for word. Search for the next matching word by N and find the previous matching word by N.
? The difference with/is that a forward (down) lookup and a backward (up ).
Replace
Command for full-text replacement: % S/AAAA/BBBB/g where AAAA is the one you want to find (replaced) in the text, and BBBB is about to replace AAAA, % indicates full-text search. It can be replaced by other methods, for example, 1, 12 S/AAAA/BBBB/g. It indicates search for AAAA in lines 1st to 12th of the text and replace it with Bbbb, G is a part of the command. The same friend C, E, I, here g means that you do not need to confirm to replace it directly. If you replace it with C, you must confirm each replacement. e indicates that the error is not displayed, And I indicates that it is case-insensitive.
Repeated commands

1. Use. Repeat the previous action in normal mode.

2. In command mode, use the direction key to select the previous action,

:!! Repeat last system command.

:! Explain select a previous system command

: Explain select a previous command

Enter the first few letters, and then use the tab or navigation keys to automatically complete the previous commands.

3. All of the above are single command records. Another method is to record a series of actions.

(1) start with the "q {register}" command, and subsequent actions will be recorded in the register named register. The given register name must be a letter between A and Z.

(2) execute the operation you want to perform.

(3) Press Q to end the record of the command (note that Q is only a character and do not enter any additional characters ). now you can run the recorded record macro using the "@ {recording}" command.

Just like most Vim commands, adding a number before @ {recording} allows the command to repeat multiple times.

Undo and redo

U undo the previous operation.

C + R: Restore the Undo operation in the previous step.

U: Undo operations within a row

Open a file

Vim filename: open or create a file named filename.

VIM + N filename: open file from row n

VIM + filename: open file from the last line

VIM +/pattern file: open the file from the first place where pattern appears.

Multi-line comment and Delete comment
1. Insert comments
C + V enters column Mode
Enter the insert mode in uppercase "I", enter the extension annotator "//", and then press ESC
2 Excluding comments
C + V
Select the annotator to delete and press d to delete it.
Multi-tag and Multi-Window
http://blog.csdn.net/fuxingdaima/article/details/8658342
Record and playback commands
http://man.chinaunix.net/newsoft/vi/doc/usr_10.html#10.1
1. "Q{register}"Command to start a key record and save the result{register}In the specified register. Register names can be represented by any letter from A to Z. 2. Enter your command 3. Enter Q (no character is needed later) to end the record. Now, you can use "@{register}"Command to execute this macro.
Example:
QA startup record, and use register a ^ to move to the beginning of the line I # include"<Esc>Enter # include "$ move to end a" at the beginning of the row"<Esc>Add double quotation marks (") J at the end of the row to move the Q end record to the next row
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.