I. Mobile
- H, J, K, L corresponds to left, bottom, top, right
- W move the cursor forward a word
- B. move the cursor one word backward.
- NW move cursor forward n words
- NB moves the cursor n words backward
- $ Move the cursor to the beginning of the line
- ^ Move the cursor to the first letter of the current row
- ) Move the cursor to the next sentence.
- (Move the cursor to the previous sentence.
- Gg move the cursor to the first line of the page
- G move the cursor to the last line of the page
- NJ move n rows down
- Ng jumps to line N
- H move the cursor over the screen
- M move the cursor to the center of the screen
- L move the cursor to the bottom of the screen
- FX moves the cursor to the next X of the row
Ii. Cut and copy
- <Shift-V> select text (visualization)
- V select text
- D. Cut the selected content to the clipboard.
- Y. Copy the selected content to the clipboard.
- Dd deletes the current row
- DW cut a word (or DAW)
- YY copy the current row
- CC cut the current row and enter the insert mode
- DFS cut the character from the current cursor to the next S
- C $ Delete the characters from the cursor position to the end of the line and enter the insert mode
- D $ Delete the character from the cursor position to the end of the line
- P Paste
Iii. insert and replace operations
- I insert in the current character
- I insert at the beginning of the current row
- A is inserted to the right of the Current Character
- A is inserted at the end of the current row.
- O Insert at the bottom of the current row
- O Insert above the current row
- R replaces a single character
- CL to modify a character
- CC to modify the entire line
Iv. Save
- : Q exit
- : Q! Force exit
- : W save
- : WQ disk storage and exit
- : New file name New File
5. window operations
- <C-H, J, K, L> switch to the upper and lower left windows.
- <C-H, J, K, L> window up and down
- WM: wmtoggle open the browser window
- F8 open or close the taglist window
- : Close current window
- <C-W> switch activity window
- : Only close other windows and keep only the current window
- : Split Horizontal Split Window
- : Vsplit Vertical Split Window
- : 4 split the window and make the new window only have four rows
- <C-U> text scroll up half screen
- <C-D> text scroll down half screen
- <C-F> scroll the whole screen forward
- <C-B> scroll back the whole screen
- ZZ current row is set to the center of the screen
- The current ZT row is placed at the top of the screen.
- ZB current row is placed at the bottom of the screen
- : Previous move to the previous file
- : Next move to the next file
- : 2 next skip two objects forward
- : Last move to the last file
- : First move to the first file
- Cal open the calendar window
Vi. Redo and search replacement
- X Delete the current character
- U undo
- <C-R> Redo (UNDO reverse)
- /Text: Search for text. After searching, use N to search for text and N to search for text.
- ? Text: Search for text. After the search, use N to search for text and N to search for text.
- /Text/> Search for a single word text
- //> Text/> Search for a single word text
- /^ The only match the word with the first line
- /The $/> only matches the word with the first line
- J. concatenate multiple rows into one row
- Gu: The current word is capitalized.
- Gu: The current word is lowercase.
- The current guu row is capitalized.
- The current guu row is changed to lowercase.
- : S/from/to replace the current row from with to, and replace only the first one (: S/from/to/G indicates replacing all of the current row)
- : 1, 5S/from/to replace from 1 to 5 rows from
- : % S/from/to/g replace all from with
VII. Common Vim setting commands
- : Set ignorecase ignore size
- : Set noignorecase exact match
- 3. Set nohlsearch to disable highlighted display
- 4.: Set hlsearch to enable highlighted display
- 5.: set number: displays the row number.
- 6.: Set nonumber does not display the row number
- 7. The Vim configuration file is _ vimrc
8. Jump (bookmarks)
: Jumps to list jump history
''Back to the place before the jump
Ma sets the current behavior bookmarks
'A jump to bookmarks
: Marks
'Start point before this jump
"The last position of the cursor when the file was last edited
[Start position of the last modification
] End position of the last modification
9. Miscellaneous
: Map list key-value ing
: Vmap list visualization key-value ing
: NMAP lists normal key-value ing
: IMAP list inserted key-value ing
: Cmap LIST command line key-value ing
: OMAP list system key-value ing
: Imap <F2> <CR> date: <ESC>: Read! Date <CR> kJ defines F2 as the insert date