Common operations
Delete command:
-
Dd: deletes the line where the cursor is.
-
NDD: Delete N lines
-
D: Deletes the contents from the cursor to the end of the line
-
DG: Delete the content at the end of the file where the cursor is
Copy and cut commands:
-
Yy: Copy the current line
-
Nyy: copy the current n lines
-
Dd: cuts the current row
-
NDD: Cut the following N lines
-
P: paste
Replace and cancel commands:
-
R: replaces the character where the cursor is
-
R: Replaces characters starting at the cursor, ending with ESC
-
U: removed
Search for replacement commands:
-
/string: searches for the specified character
Save and exit commands:
-
:w Saves the modification
-
:w [filename] Saves as the specified file
-
:wq Saves the configuration and exits
-
ZZ shortcut keys to save the changes and exit
-
:q! Exit without saving the changes
-
:wq! Save the changes and exit
-
: q exit
Vim uses techniques
- The file name: r
In edit mode, you can import the contents of a specified file under the current cursor
- :r ! The command
In editing mode, you can import the command execution result into a file, for example: :r! date
Define shortcut keys
Example: map shortcut key trigger command
:map ^P I#<ESC>
^P= >Ctrl + V + P I => Enter insert mode at the beginning of the line # => Insert character # <ESC> => Press ESCCopy the code
Insert # at the beginning of the current line of the cursor, i.e. comment the current line
:map ^B 0x
Copy the code
Deletes the first character of a line
:map ^H [email protected]<ESC>
Copy the code
Insert another line into my mailbox