Git provides some nice utility functionality that can make a vim development
environment much nicer. With recent updates to Vim it can now execute a command
for every item in the quickfix list (
:cdo) and location list (
features work together quite nicely.
This new functionality has been introduced to vim from version 7.4.858 and is therefore available in vim8 and also available in neovim.
The Old Way
Back in 2011 I wrote a post about doing search and replace across multiple files with just the basic vim functionality. It’s quite common to use the arg list because its easy to add to:
and it’s easy to execute commands:
The New Way
Now that we can execute a command from the quickfix and location lists it is much easier to make larger, more controlled edits with the help of other features or plugins.
If you use
neomake for linting, a compiler via the
command, the built in
:vimgrep commands or any number of other
plugins that integrate with these lists, such as
vim-fugitive, you can take advantage of
Then you can execute commands like this:
Git Is Awesome
Git is incredibly powerful and I often use a couple of features that are often overlooked:
git ls-files- recursively list all the files in the repo
git grep- grep through all the files in the repo
One of the reasons these commands are so good is because by default they will
ignore the items in the
node_modules directories readily available is great! Best of all, these
tools are available on just about every machine I work, on including the
machines of other peoples that I pair with.
ctrl-p in vim and rather than relying on yet another third party tool
ag, I’ve configured
crtl-p like this:
1 2 3 4 5
It is super fast and I haven’t come across a situation where I need ctrl-p for a
large enough non-git repo and
find wasn’t good enough for… yet!
If you use vim-fugitive, there is also
:Ggrep command that behaves much like the builtin
:grep command, but it
will ignore the
.gitignore items. I use this quite a lot too:
Then you can execute commands in the same manner as above:
Because I use this so often, I’ve added the following mapping to my config to automatically search for the token under my cursor: