Vim Tips Wiki
Advertisement

Tip: Search and replace in all buffers

Created: August 9, 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

Advertisement