git-jump is an amazing little script that can be used to start Vim with the quickfix list populated with interesting things:
- The beginning of any diff hunks.
- The beginning of any merge conflict markers.
- Any grep matches, including the column of the first match on a line.
- Any whitespace errors detected by
git diff --check.
$ git jump diff $ git jump grep GetUser
But the original script is written from a shell perspective so it always opens Vim and thus can't be used to populate the quickfix list from within Vim. Bummer…
This hack makes it possible to get two behaviors out of
git-jump for the price of one.
When executed in an interactive context, it starts Vim with the list:
$ git jump diff
when executed in a non-interactive context, it outputs the list:
$ git jump grep foo | grep -v bar
Having the same feature inside and outside of Vim is quite handy but:
:cexpr system('git jump diff')
is a lot to type! Let's turn that into a proper command:
:command! -bar -nargs=* Jump cexpr system('git jump ' . expand(<q-args>))
that we can use easily:
:Jump diff :Jump merge :Jump grep foo