My main blog: half an acre of fangtang
1. Search for characters in the row where the cursor is located in Normal Modef{char}
Command to move the cursor to the position where the character is located.;
, Roll back to search,
2. search and replace the cursor in the row in Normal Mode:s/target/replacement
The target and replacement are replaced by the replaced character or string and the replaced character or string, respectively.&
Command, used in Normal Modeu
Manually control the use of each replacement in Normal Mode:%s/target/replacement/gc
In this way, VIM will ask whether to replace each time there is a replacement, there are the following options:
y
: Replace the match here
n
: Ignore matching here
a
: "All" -- replace all the matching values here.
l
: "Last" -- replace the match and exit.
q
: Exit the replacement process.
<C-e>
: Scroll up the screen
<C-y>
: Scroll down the screen
3. Search for words under the current cursor in Normal Mode*
4. one-click movement and one-click modification --.
Paradigm
5. When writing code, please immediately go back to the normal mode and cut the thinking unit into blocks, so that you can easily make a mistake by pressingu
During the rollback operation, you can connect to the previous idea and then modify it. When appropriate, the line feed operation uses<Esc>o
In this way, there will be a smaller granularity for revocation, which is conducive to encoding operations
6. In normal mode, pressdb
, Reverse deletes the content from the starting position of the cursor to the beginning of the word, but the last character remains unchanged.
7. In normal mode, pressb
Will move the cursor to the beginning of the word
8. In normal mode, pressdaw
To delete a word.
9. In normal mode<C-a>
And<C-x>
Perform the add and subtract operations on numbers separately. When the number is not included, they are added or subtracted one by one. However, if the number prefix is included, you can use them to add or subtract any integer, for example, move the cursor to number 5 and execute10<C-a>
It is changed to 15. If the cursor is not on the number<C-a>
And<C-x>
The system looks for a number in the forward direction of the current row. If it finds a number, it jumps directly to it.
10. In normal mode, pressyyp
The current row is copied and pasted to the next row.
11. Adding the number of times in normal mode indicates repetition, for example2dw
Ord2w
Both indicate to delete two words,2u
It indicates two steps to be rolled back, and so on, but it is best to use it only when necessary.
12. In normal mode, pressdl
Delete words under the current cursor, but do not enter insert mode. Pressdap
Delete the entire paragraph
13. In vim, operator + action command = operation. When an operator is called twice consecutively, it acts on the current row. For example:dd
Delete the current row,>>
Indent the current row,gU
The command is a special case, you can usegUgU
, You can also use the simplified versiongUU
To make it act on the current line. The common operator commands are as follows:
c
: Modify
d
: Delete
y
: Copy to register
g~
: Reverse case
gu
: Convert to lowercase
gU
: Convert to uppercase
>
: Increase indentation
<
: Reduce indentation
=
: Auto indent
!
: Use an external program to filter the rows that {motion} Spans
Vim common skills summary 2