NOTE: The original git-jump
now supports the flag --stdout
, which makes this hack redundant, but I will keep it for posterity.
To use it from Vim, just add the new flag to your custom command:
:command! -bar -nargs=* Jump cexpr system('git jump --stdout ' . expand(<q-args>))
Thanks to @rafikdraoui for the heads-up, @yoichi for the commit, and to everyone else for their interest in this little hack.
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
.
Example usage:
$ 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
Appreciate the response @romainl, I ended up narrowing it down to an offending plugin (dhruvasagar/vim-prosession#84).