Reputation: 65
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. like
:%s/V1/V2/g
Is there a easiler way to do this?
Upvotes: 2
Views: 314
Reputation: 196496
It's command-line mode, not "command mode".
Set your :help argument-list
to the desired list of files:
: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
.
Start Vim with each desired file as argument:
$ 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
Upvotes: 3