I want to change some words in several files using VIM. To do this, I found out about Greplace, which appears to be made to do just that. However, in the documentation there is no sample of the syntax of Greplace (there is a sample of Gsearch, but I need the replace function).
Say I want to change “foo” for “bar” in all “.asp” files, how could that be achieved with Greplace (or any other method). I do not care about confirmation (it’s fine if it requires confirmation; it’s also fine if it does not).
It’s trivial to do without a dedicated plugin.
:bufdoruns the following commands on all buffers.%s/foo/bar/gereplaces foo with bar on all lines and all occurrences in each line. Theeflag makes sure:sdoesn’t emit an error if it doesn’t find foo, since foo may not exist in all the files.|is Vim’s way of separating multiple commands to run. See:help :barupdatesaves the file back to disk, only if any changes were actually made.