Vim Tips Wiki
Advertisement

Proposed tip Please edit this page to improve it, or add your comments below (do not use the discussion page).

Please use new tips to discuss whether this page should be a permanent tip, or whether it should be merged to an existing tip.
created August 10, 2007 · complexity basic · author Sam Inverso · version 6.0

Simple way to search and replace in all buffers:

:bufdo %s/pattern/substitution/ge | update

bufdo – apply the following command to all buffers – see :help :bufdo.

%s – search and replace the whole file

g – change all instances in a line

e – avoid an error when the pattern doesn’t exist in a buffer

update – write the file only if changes were made

See also :help :argdo.

Comments

Shouldn't the '|' be '<bar>'??


Advertisement