Find and Replace by Hand
In the text above, we are going to change the content to Word copy
Maybe we can use the following command.
:%s/content/copy/g
The above command changes all the content words in the text to copy, but we do not want the content in the second line to be replaced.
We can execute the following command
Search content We can use
/content
You can also put the cursor on the content Word, and then press *
, VIM will automatically search for the word where the cursor is located.
cw
command to delete the current Word and enter insert mode, we type the word copyto be replaced, press ESC to exit Insert mode, and enter into normal mode.
By TIP4, we used to n
move the cursor to the next matching position in the last search, using the .
last change operation repeated. If you encounter a word that you do not intend to replace, skip it .
and use it once n
.
[Practical.vim (2012.9)]. DREW.NEIL.TIP04 Study Summary