当前位置:网站首页>VIM string substitution

VIM string substitution

2022-07-08 01:56:00 Pengshiyu

grammar :

:<range> s/<search_string>/<replace_string>/<modifier>

Parameter description

- range -  Define execution “ Find and replace ” The scope of the function , There are two different values :
    - % -  Execute... On the entire file 
    - <start _line> <end_line> -  Perform operations on a specific set of lines 

- search_string -  String to replace 

- replace_string -  Replace the new string of the old string 

- modifier -  Determine substitution behavior , There are several different values :
    - g -  Global replacement 
    - gc -  Ask for confirmation before each replacement 
    - gn -  Ignore the replacement function and highlight the search results .

Example

#  Global replacement a by b
:%s/a/b/g

Reference resources
Vim Find and replace string commands

原网站

版权声明
本文为[Pengshiyu]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/189/202207080034156553.html