The joy of :bufdo
Tuesday 27 January 2004 - Filed under Software
If you use vim, then you may have discovered that its documentation, while extensive, is nearly impenetrable. One operation I often have to do is
$ for x in [list of files]; do > sed -e '[some substitution]' < $x > $x.bak > mv $x.bak $x > donesince most Unix-based editors don’t offer multi-file replace. It turns out that, sometime between 5.3 and 6.x, vim has added the
:bufdo command, so this operation is much simpler as
- you needn’t leave the editor, and
- you needn’t maintain a list of files, provided you’ve opened them all in the editor.
:bufdo. (See “impenetrable documentation”, above.)
2004-01-27 » Stephen
