vim use

1、

Every time you copy the code, if there are comments like // in the code, it is easy to mess up the format. This can be avoided by the following settings.

 

set paste and then enter insert mode to paste, the code will not be automatically indented. When typing code, you need to automatically indent, and then change it back set nopaste

The most convenient way is to add a sentence to .vimrc:

 

set pastetoggle=<F9>

Later in insert mode, just press the F9 key to toggle automatic indentation.

 

2、

Whole line (multiline) copy and paste in vim editor

copy

1) Single line copy

In command mode, move the cursor to the line to be copied and press "yy" to copy;

2) Multi-line copy

In command mode, move the cursor to the first line to be copied, and press "nyy" to copy n lines; where n is 1, 2, 3...

paste

In command mode, move the cursor to the line to be pasted and press "p" to paste

Linux vim batch annotation

1) ctrl+v use the arrow keys to select the range up and down;

2) Shift+i to enter edit mode, add "#". Then press esc to exit (it can also be understood as running batch add); the annotation has been added at this time

Bulk delete added comment lines.

ctrl+v Use the arrow keys to select the range to remove the annotation, and press "x";

 

3、

w: move the cursor forward one word b: move the cursor backward one word 0: move the cursor to the beginning of the current line ^: move the cursor to the first letter of the current line $: move the cursor to the end of the line

u: undo the last action

U: Undo all recent changes to a row

 

4、

Chinese garbled

Edit the ~/.vimrc file and add the following lines:

set fileencodings=utf-8,ucs-bom,gb18030,gbk,gb2312,cp936

set termencoding=utf-8

set encoding=utf-8

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326262198&siteId=291194637