The argument list

category applies to 5 screencasts and 2 articles:

Run time:

Vim doesn’t have a built-in command for project-wide find and replace operations, but we can perform this task by combining primitive Ex commands such as :substitute, :argdo, and :vimgrep. We’ll look at two possible strategies: first using the arglist, then the quickfix list.

Watch screencast

Combining :vimgrep with git ls-files

The vimgrep command uses Vim’s native regular expressions to search the contents of multiple files. There are several ways that we can specify the list of files to look inside, including * and ** wildcards. It would be handy if we could instruct vimgrep to look inside all of the files in the current project, excluding those listed in the .gitignore file. That’s where the git ls-files command comes in.

Continue reading

Combining :vimgrep with ack -f

I love the way that ack let’s me specify the files to search inside. For starters, ack does the right thing by ignoring the contents of VCS directories, backup files, core dumps etc., which gives a good signal to noise ratio. On top of that, ack provides a convenient syntax for specifying filetypes to include or exclude from the set (see ack --help-types). I can target ruby files only with the --ruby option, or everything but ruby files with --noruby.

Continue reading
Run time:

vimgrep is Vim’s built-in command for searching across multiple files. It’s not so fast as external tools like ack and git-grep, but it has its uses. vimgrep uses Vim’s built-in regex engine, so you can reuse the patterns that work with Vim’s standard search command.

Watch screencast
Run time:

The :argdo command allows us to execute an Ex command across all buffers in the arglist. To demonstrate, we’ll use the example of running the :substitute command across multiple files, then we’ll see how to revert or save the changes. We’ll also compare the :argdo and :bufdo commands, and consider when it’s appropriate to use each one.

Watch screencast
Run time:

The arglist wouldn’t be much use if we had to quit and relaunch Vim every time we wanted to change its contents. In this episode, we’ll learn how to set the contents of the arglist using the :args command, which can receive filepaths, globs, or even backtick expressions.

Watch screencast
Run time:

The arglist feature complements Vim’s buffer list. In this episode, we’ll learn a handful of commands for traversing the arglist. We’ll see that it’s useful to think of the arglist as a stable subset of the files in the buffer list.

Watch screencast