I have several files where I want to change a word in several files from oldWord to newWord.

Please note I want to do this with the new cpo feature. I also would like to do this in one command line chain, rather than one command at a time.

Should this command do it? Or is there a better way do this in VIM?

:set hidden | :vimgrep oldWord ./gulp-tasks/*.s | :cdo s/oldWord/newWord/g | :set wall  ?
  • That answer is outdated, there is a way to do this with the new quick fix window and cpo command. Also, I want to do this with chained commands in one line rather than one at a time.
    – dman
    Dec 13, 2017 at 17:54
  • 2
    that answer is not out of date. The first answer provides an :argdo/:bufdo method, the second :cdo method, and the 3rd uses the tried and true unix shell method. All of which are valid have there own pro's and con's. I am not aware of a :cpo command. I imagine you are looking for :cdo / :cfdo. See :h cdo. Dec 13, 2017 at 17:59

1 Answer 1


I imagine you meant something like this

:set hidden
:vimgrep /foo/ dir/*.s
:cfdo %s/foo/bar/g | w

All in one line:

:set hidden | vimgrep/foo/ dir/*.s | cfdo %s/foo/bar/g | w

Related Vimcasts episode: Project-wide find and replace

For more help see:

:h :vimgrep
:h :cfdo
:h 'hidden'

Not the answer you're looking for? Browse other questions tagged or ask your own question.