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.

Tags:

One Response to “Vim arglist”

  1. Quoth Loevborg:

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

Leave a Reply

You can use these tags in comments (Note: HTML is automatically escaped inside <pre> tags, nowhere else, so if you post source code, put it in <pre>):

<pre lang="some_programming_language"> 
<em>
<strong>
<a href="url">

NOTE: Comments are automatically spam-filtered. If your comment fails to appear, it was likely munched by the filter. Try not to link-spam or post anything that looks like it was typed by a robot.