内置方式:/c
为:substitute
命令指定"confirm"标志,并回答y
四次,然后中止q
.你也可以自动化:
:call feedkeys('yyyyq') | %s/{pattern}/{string}/gc
Run Code Online (Sandbox Code Playgroud)
插件方式:我的PatternsOnText插件提供了一个:SubstituteSelected
命令:
:%SubstituteSelected/{pattern}/{string}/g 1-4
Run Code Online (Sandbox Code Playgroud)