How can I perform a command for each item in the quickfix/location

list? Starting from Vim 7.4.858 Vim provides the new commands :cfdo, :cdo, :lfdo and :ldo. They work by iterating over all items in the quickfix list and performing a command on each. The difference is, that the :lfdo and :ldo commands iterate over the location list entries, while the :cfdo and :cdo commands operate on the items in the quickfix list. Also, the :cfdo and :lfdo operate on all different files, while the :cdo and :ldo commands operate on each item in the quickfix/location list. For example you could vimgrep all C files in the current directory for a search string “Foobar”:

    :vimgrep /Foobar/ *.c

and as this populates your quickfix list, you could simply replace all occurences by using:

    :cdo :%s/Foobar/Foobaz | upd

Comments (1)


Pepsh Pepshinsky

Let’s see you to :help viminfo-file-name (option -i) :set viminfofile=NONE


Speak Your Mind