Vim processes data in a memory buffer
If you do not specify a file name when you start Vim, or if the file does not exist, VIM will open a new buffer to edit.
H move one character to the left
J Move down one line
K Move up one line
L Move one character to the right
PageDown (ctrl+f) turn over a screen of data
PageUp (ctrl+b) Flip a screen
G moves to the last row of the buffer
Num G moves to the first NUM line in the buffer
GG moves to the first row of the buffer
Q! Cancels all modifications to the buffer data and exits
W filename Saves the file to another file name
X Delete the character at the current cursor position
DD deletes the cursor in the row
DW Delete Word with cursor
d$ Delete content from cursor to end of line
J stitching rows (current and next lines, removing line breaks at the end of the current line)
U undo Previous Edit Command
A append data after the current cursor
A append data at the end of the current line
R Char replaces a single character at the current cursor position with Char
R text overwrites the data at the current cursor position with text until the ESC key is pressed
Some commands allow numbers to be used to specify how many times the command repeats: 5J,10DD, etc.
Cut, copy
When vim deletes data, it actually saves the data in a separate register. You can use the P command to retrieve the data. (This attribute can be deleted for clipping)
Copy operation with the y command (yw copy the word, y$ copy to the end of the line, you can also copy multiple lines in the visual mode, press the V key into the visual mode, select the content to copy, press the Y key), after the copy succeeds, move the cursor to where you want to paste, press the P key
Find, replace
/texttofind
Pressing the N key indicates the next
: s/old/new/replaces the first occurrence of old
: S/old/new/g replaces all of our old
:%s/old/new/g replaces all old in the file
:%S/OLD/NEW/GC replaces all old in the file, but prompts each time it appears
: N,ms/old/new/g replaces all old between line number N and M
Linux VI Editor