Vim arglist

Note to self: If you want to open multiple files in Vim via a glob, you can pass them in on the commandline. They end up in the arglist (see also :h arglist). But once you start Vim, you can also set a new arglist via

:n *glob*

using some glob.

This has the very beneficial side-effect of opening all matching files in Vim buffers. This is the only way I know of to open multiple files via a single command once Vim has started. (May be other ways I don't know of though.)

Once you have an arglist you can do spiffy things with :argdo. For example, search / replace across mulitple files. This is what I needed to do today.

:argdo s/regex/replacement/ | update

Side note, to delete all buffers that currently exist:

:bufdo bd

I find it handy to map that to something in normal mode, because I need to do it so often.

November 19, 2007 @ 8:13 PM PST
Cateogory: Programming
Tags: Vim

1 Comment

Loevborg
Quoth Loevborg on January 17, 2008 @ 5:47 PM PST

Thanks for the last tip! ":bufdo bd" does what ":%bd" does not.

Speak your Mind

You can use Markdown in your comment.
Email/URL are optional. Email is only used for Gravatar.

Preview