Vim-) while confirming and searching for replacement
When performing simple global search replacement, you can use the following ex command:
: % S/which/what/g
It is easy to use
% |
Each row (everyline) |
S |
Replace (substitue) |
Which |
Search content |
What |
Replaced content |
G |
Global on that line) |
In this way, you can quickly implement the global search and replacement function, but sometimes we do not want to complete all the replacement operations at a time, it is possible that we only want to replace a part.
To implement this operation, we first think of the execution sequence as search-> modify? -> Modify-> Find Next-> modify? -> Modify.
The specific commands can be executed in the following order:
/Which |
Search |
Cwwhat [ESC] |
Chang word |
N |
Next, no need to replace |
N |
Proceed to the next step and modify it. |
. |
. (Dot) is used to repeat the previous operation, that isCwwhat [ESC] |