[英]Vim: The way to execute same command in command-line mode multiple times
I'm recently working on a project in vim, and I need to execute the same command to different files which are in the same folder in command-line mode multiple times.我最近在 vim 中处理一个项目,我需要在命令行模式下多次对同一文件夹中的不同文件执行相同的命令。 like
喜欢
:%s/V1/V2/g
Is there a easiler way to do this?有没有更简单的方法来做到这一点?
It's command-line mode , not "command mode".它是命令行模式,而不是“命令模式”。
Set your :help argument-list
to the desired list of files:将您的
:help argument-list
设置为所需的文件列表:
:arg /path/to/dir/*.xyz
Perform your substitution on every file in the argument list and write it if there was a change:对参数列表中的每个文件执行替换,并在有更改时将其写入:
:argdo %s/V1/V2/g | update
See :help :arg
, :help :argdo
, :help :update
.请参阅
:help :arg
、 :help :argdo
、 :help :update
。
Start Vim with each desired file as argument:以每个所需文件作为参数启动 Vim:
$ vim /path/to/dir/*.xyz
Perform your substitution on every file in the argument list and write it if there was a change:对参数列表中的每个文件执行替换,并在有更改时将其写入:
:argdo %s/V1/V2/g | update
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.