29, vi and vim usage Detailed


vi similar to a text file in windows for plain text files

vim: Expert Edition file editor for shell program file type, colored, self-checking grammar

General mode shortcuts

O: the cursor to the first line

$: The cursor to the end of line

H: cursor to the head of the entire file;

M: Move the cursor to the middle of the file

L: the cursor to the end of the entire file

11gg: Move the cursor to the line in the first 11 rows

v: speed selection (selection lateral) V: vertical selection

dd: delete the current line; 2dd: Remove two rows down

yy: Copy the current line; 2yy: Copy down line 2 p: Paste

u: Undo

ctrl + r: Reverse revocation

: Repeat the last operation

Conversion from the usual mode to the edit mode (CTRL + C: enter the edit mode by the normal mode)

a: after the cursor in the appended

I: inserted in front of the cursor

o: adding a new one, and to be appended to the cursor

R: Replace the current character, it would have been replaced; r: Replace the current content only once;

Conversion from the usual mode to the command mode (CTRL + C: the command mode entering normal mode)

Use the arrow keys can be used to command displayed

: W: Save the file

: Q: quit

: Q !: Force Quit

: Wq: Save and Exit

: W [file]: Save to file

: N1, n2 w [file]: The rows n1 to n2 saved as a file

: Set nu: show line numbers

: Set nonu: Cancel line number

: / Char: N upward search, n down search

:? Char: N search upwards, n down search

:% S / a / b / g: to replace a whole b

: N1, n2s / a / b / g [c]: a search among n1, n2 and replaced b, c can be a one acknowledgment parameter;

Guess you like

Origin www.cnblogs.com/LiuChang-blog/p/12313561.html