Batch replacement of strings in Vi
Replace strings in batches in Vi.
A. replace all in the file:
% S # abc # def # g (replace all abc files with def)
For example, replace "bkjia.com" in a text file with "bkjia.net ":
: % S # bkjia.com # xwen.net # g (such as # in the file, available/replaced, such as % s/bkjia.com/xwen.net/g)
B. Partial replacement in the file:
Replace "abc" in 10 to 50 rows with "def"
: S # abc # def # g (if the file contains #, available/replaced,: % s/abc/def/g)
If the above command is followed by c after g, a prompt will be displayed before replacement to confirm the user (conform) whether to replace. For example
: % S # bkjia.com # bkjia.net # gc
Vim Learning Guide
Quick learn Vi Editor
Powerful Vim Editor
Build a Vim Development Environment on CentOS 6.2
Install the highlighted Vim editing tool in CentOS 5.4
Vim tips: C language settings
Set the Vim row number in Ubuntu
Vim editor basic tutorial
This article permanently updates the link address: