VIM
3 modes
in edit mode
1. cursor moves word by word
w move to the beginning of the next word
e move to the end of the current or next word
b move to the beginning of the current or previous word
2. The cursor jumps within the line
0 absolute line start
^ first non-whitespace character at the beginning of a line
$ absolute line ending
3. Jump between lines
#G jump to line #
G jump to the last line
In the last line mode, you can directly give the line number
4. Flip the screen
Ctrl+f scroll down one screen
Ctrl+b scroll up one screen
Ctrl+d scroll half screen down
Ctrl+u scroll up half screen
5. Delete a single character
x deletes the single character where the cursor is
#x deletes # characters at the cursor position and backwards
6. Delete command: d
dd delete the line where the cursor is located
#dd delete the line where the cursor is and the # line below
dG deletes all paragraphs from the line where the cursor is located to the end of the text
7. Copy
yy copy a line
8. Paste
p paste
9. Delete
dd delete a line
10. Delete and convert to input mode
cc delete a line and go to input mode
11. Revocation of order
u undo the previous operation
#u undo the previous # operations
12. Visual operation
v Cursor can be selected by character by mouse
V cursor press to select
13. Find
/ search down from the cursor
n : select next
14. Edit multiple files with vim
vim FILE1 FILE2 FILE3
:next switch to the next file
:prev switch to the previous file
:last switch to the last file
:first switch to the first file
quit
:q quit the current file
:qa quit all files
15. Window Split
Ctrl+w ,s split window horizontally
Ctrl+w ,v split the window vertically
Ctrl+w up, down, left and right keys to move the cursor to each window
16. Multi-file editing in sub-windows
vim -o horizontally split window display
vim -O vertical split window display
Example: vim -o FILE1 FILE2
17. Save
:w save own file
:w /path/... save as
18. Interact with the shell
:! COMMAND
19. Display line numbers
:set nu display line number
:set nonu cancel line numbering
20. Un-highlight
: set nohlsearch temporarily, after exiting and entering VIM, it will be highlighted
:noh Permanent, if temporarily invalid, first look for a random word, then cancel.