"%s//second/g"
People with vim know that this is to replace all the "most" with the meaning of "second". In fact, Vim's search and replace function is very powerful, good use can greatly improve efficiency.
The Find and replace command for VIM is as follows: :{作用范围}s/{目标}/{替换}/{替换标志}
- Scope of Action:
- Current Line S
:s/most/second/g replace all "most" of the current line with "second"
- Full-Text%s
:%s/most/second/g replace All "most" of the full text with "second"
- 8-15 row 8,15s
:8,15s//g/second to replace all "most" of the 8-15 rows with "second"
- The current line and the next 5 rows . , +5s
:., +5s/most/second/g replace the current line with all "most" of the next 5 rows to "second"
- Target: Support Regular expressions
- Replace flag:
:%s/most/second/GC replace All "most" of the full text with "second", but each one needs to be confirmed
-
- At this point each replacement will prompt: Replace with second (y/n/a/q/l/^e/^y)?
- Y confirm the replacement of the current "most"
- n does not replace the current "most"
- A Replace All
- Q Exit Find mode
- L Replace the current position and exit
- ^e window moves down one line
- ^y window Move up one line
How to find and replace in vim