One. Cut:
1. To delete from the current cursor to the next word, enter: DW
2. To delete from the current cursor to the end of the current line, enter: d$
3. To delete the entire row, enter: DD//can use DND to delete multiple rows n for the number of rows
4. To repeat an action, precede it with a number: 2w
5. The format for modifying commands in normal mode is:
operator [NUMBER] Motion
which
Operator-operators, which represent things to do, such as D for deletion
[NUMBER]-numbers that can be appended, representing the number of times the action repeats
Motion-action, which represents the movement of the text on which it is manipulated, such as w for word (word),
$ represents the end of the line and so on.
Two. Revocation
- To undo a previous operation, enter: U (lowercase u)
- To undo the changes you made in one line, enter: U (uppercase U)
- To undo the previous Undo command and restore the previous operation results, enter: Ctrl-r
Three. Copy and paste
- Press the operator v when copying and select the text you want to copy under the visual interface.
- Operator y copies the text and p pastes the previously copied text.
Four. Jump
- The ctrl-g is used to display the current cursor location and file status information.
- G is used to jump the cursor to the last line of the file.
- Type a line number first and then enter uppercase G to move the cursor to the line represented by the line number.
- GG is used to jump the cursor to the first line of the file.
Five. Search matches
- The input/Then followed by a string is the string that is found in the currently edited document.
- Input? followed by a string is the reverse lookup of the string in the currently edited document.
- Pressing the N key after a search is done repeats the last command and can be checked in the same direction
- Find the next matching string, or in the opposite direction of uppercase N to find the next matching string.
- If the current position of the cursor is parentheses (,), [,], {,}, pressing% will move the cursor to the pair of parentheses.
Six. Replace
- Replace the first string in a line with old as the new string, enter: S/old/new
- Replace all of the strings in a row with old as the new string, please enter: s/old/new/g
- Replace all the strings in the two lines with old for the new string, enter: #, #s/old/new/g
- Replace all the strings in the file with old for the new string, please enter:%s/old/new/g
- Ask the user to confirm that each replacement needs to be added with the C flag:%S/OLD/NEW/GC//full-text replacement recommended
Seven. Text modification (insert mode)
- Enter lowercase r to replace a single character under the cursor.
- Enter the uppercase R to enter the replacement mode until you press <ESC> to return to normal mode.
Eight. Auto-complete
- Ctrl-n from the top down
- Ctrl-p from bottom to top
Nine. Execute external commands in VIM mode
Take a look at some practical examples:
(MS-DOS) (Unix)
:!dir:!ls-Used to display the contents of the current directory.
:!del filename:!rm filename-Used to delete a file named filename.
Vim Editor Common commands