01 January 2023

How to do substitution in all files at once in vim?

Vim search replace all files in current (project) folder

e.g. to substitute 'bar' for 'foo' in all Python files in current directory

Within vim, run the commands below,

:arg *.py
:argdo %s/foo/bar/gce | update


:arg *.py means we will do substitution in all Python files in current
directory

'update' means to write a file only if changes have been made.


No comments:

Post a Comment