vi shortcut key

1. Exit the editor

:w writes the buffer to the file, i.e. saves the changes

:wq save changes and exit

:x save the changes and exit
:q exit, if the buffer has been modified, you will be prompted

:q! Force quit, discard changes

2. Find and replace

/pattern Search backwards for the string pattern
?pattern Search forwards for the string pattern
"\c" ignore case
"\C" case sensitive

n next match (if /search, next down, ?search is next up)
N previous match (same as above)
:%s/old/new/g Search the entire file, convert all replace old with new

:%s/old/new/gc Search the entire file, replace all old with new, and ask you to confirm whether to replace each time

3. Delete replication

dd delete the line where the cursor is located
dw delete a word (word)
d / D delete to the end of the line x delete the current character Xdelete the previous character yandcopy a line of yw copy a word y/D delete to the end of the line x delete the current character X delete the previous character yy copy a line yw copy a word y /Y copy to the end of the line
p paste the contents of the pasteboard below the current line

P pastes the contents of the pasteboard above the current line

4. Insert Mode

i Enter insert mode from the current cursor
I Enter insert mode, and place the cursor at the beginning of the line
a Add mode, place the cursor after the current cursor
A Add mode, place the cursor at the end of the line
o Add a new line below the current line, and enter insert Mode
O Add a new line above the current line and enter insert mode
Esc Exit insert mode



Guess you like

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