0

This question already has an answer here:

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  ?

marked as duplicate by Peter Rincker, janos, Herb Wolfe, statox Dec 14 '17 at 7:47

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 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 '17 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. – Peter Rincker Dec 13 '17 at 17:59
2

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.