vi editor for linux

1.vi editor (command line mode/insert mode/last line mode)

1. Insert

i 【Insert the current cursor】;
o 【Insert the header of the down line】;
O 【Insert the header of the upper line】;
I 【Insert the current header】;
A 【Insert the current tail】;
a 【Insert the next letter of the current cursor】;

2. Move the cursor

0 [Move to the beginning of the line];
$ [Move to the end of the line];
G [Move to the last line];
w [Open after the space/head of the next word];
b [Open before the space/the head of the previous word];
ctrl+w / b [move one page/half page back];
ctrl+b / u [move one page/half page forward];

3. Delete text

nx / nX [delete the next / first n characters after the cursor];
ndd [delete the current line to the next n lines];

4. Copy the text

nyw [copy and write the buffer to the next space from the cursor position];
nyy [copy the current line to the next n line and write to the buffer];
p [display the contents of the buffer];

5. Cut the text

ndd - p [delete and write out];

6. Undo the operation

u

7. Exit the specified line

ctrl+g [list the current line number];
nG [jump to the nth line of the text];

8. Exit

ZZ / ZQ 【Exit with save/Exit without saving】;

// end line mode operation

1. Replace text

s/a/x/g [replace g (all) a with x];

2. List/Cancel Line Numbers

:set nu / set nonu [display/cancel line number];

3. Jump to a line

:n [skip to line n]

4. Find characters

:/x [Find xn to find the next one];

5. Save the file

:w /wq/ [Save file/Exit save file];

Guess you like

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