This command will open all files that match your pattern in separate buffers in vim. In the following steps I'll break it apart and show you how to open them in tabs - if you're the kind of person who uses tabs.

This syntax is called command substitution. It takes the output of command and replaces it with the command itself. So when used in conjunction with vim it would replace this:

vim $(echo test)

with this:

vim test

And when you use the vim command with multiple parameters, it opens them each in a separate buffer.

If you're unfamiliar, ack is a grep-like text finder. You can use it like this:

ack "some pattern"

and it will recursively search all files trying to match some pattern.

When used with the -l option, it only outputs the names of the files rather than the matches themselves.

So the following code:

ack -l "codes"

Might generate output like this:

$ ack -l "body"

So all together, the output from ack -l "pattern" is passed directly into vim and opens each file in a new buffer.

Simply use vim's -p option to open files in separate tabs.

vim -p $(ack -l "pattern")
Dayne Dayne (57)

You probably already know how to use vim's basic undo and redo features. For a quick refresher, read this short tutorial on how to use vim redo and undo.