Cursor movement: H (left) J (off) K (UP) L (right)
Use Vim to edit a file Vim file name
Exit Vim: In command-line mode (press ESC to command-line mode),
Q! Discard all changes to exit
Wq Save all changes to exit
Delete in command line mode: X
Insert text: I, insert text before the cursor
A, insert text after a line, append
A, insert text after the current cursor
Note: ESC can also be returned to the command line mode while undoing the command currently being entered
=========================================================
Delete command d [number] motion (w stands for Word, $ for end of line)
Motion
W from the current position until the beginning of the next word, the cursor is at the beginning of the next word after it has been deleted
E-and W almost, after deletion, the cursor is located in the space after the word
$-Delete from current position to end of line
d2w-Delete Two capital letter words, 2 can change any
dd-Delete a whole line, similarly, 2DD delete two rows
The command is preceded by a number to allow the current command to execute repeatedly
Fast moving positioning
2w-cursor moves forward two words to the beginning of the
3e-Light moves forward to the end of the third word
---------Note: The same meaning as W e in the D command
0-Move to the beginning of the line
Revoke
U-undo Once
U-undo all to Operation
Ctrl-r Redo is revoked to the command
============================================================
p to paste the last delete to the next line of the cursor
r+ A letter-replaces the character at the cursor position
R can replace multiple characters consecutively
cw-changes the cursor position to the end of the word to all characters (in fact, CW also enters insert mode)
-----Note: Similarly, C $ represents changing the cursor position all the way to the end of the line
============================================================
Positioning:
CTRL+G Displays the current file information, and the row where the current cursor is located, the column
G jump to the last line of the file
GG Jump to the first line of the file
Line number +g Navigate to a row
Find:
/+string find the string in the text, n then look down, n reverse direction find
Ctrl+o fallback to the previous position of the cursor, can be reused
Ctrl+i back to the newer position
Paired:
The% cursor moves to () {} and is automatically paired to another
Replace
Replace the first string in a row with the new string, type:/s/old/new
Replace all strings in a row with old to new to string, type:/s/odl/new/g
In two specific lines (requires a known line number) for the new string, enter: line number 1, line number 2S/OLD/NEW/LG
Replace all to string input within the file:%s/old/new/g
If you need a hint: replace at the end plus C for example:/S/OLD/NEW/GC
Choose
V is the same as the mouse selection
Then enter D x to delete the current selection, or: w filename to save the current selection to a new file
When selected, enter Y to copy the selection, and p to paste the selection.
o Inserts a new line at the next line in the current cursor and enters insert mode
o Inserts a new line on the current cursor line and enters insert mode
Vim-<< Vi improved>>-Steve oualline
Publisher: New Riders
Vim Learning Notes