Vim Tips Wiki
Advertisement


Tip: Search and replace in all buffers

Created: August 9, 2007 Complexity: basic Author: Sam Inverso User:sinverso Version: 7.1


Simple way to search and replace in all buffers:

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

bufdo - applies the following command to all buffers.

%s - means search and replace the whole file

g - change all instances in a line

e - avoids the error when the pattern doesn’t exist in a file

update - writes the file only if changes were made

See also argdo

Comments

Advertisement