Skip to content

Instantly share code, notes, and snippets.

@romainl
Last active March 19, 2023 07:26
Show Gist options
  • Save romainl/5b827f4aafa7ee29bdc70282ecc31640 to your computer and use it in GitHub Desktop.
Save romainl/5b827f4aafa7ee29bdc70282ecc31640 to your computer and use it in GitHub Desktop.
Super cheap git blame

Super cheap git blame

git blame current line

:GB

git blame range

:7,13GB
:,+5GB
:?foo?,$GB
:'<,'>GB

git blame full buffer

:%GB

My Vim-related gists.

command! -range GB echo join(systemlist("git -C " . shellescape(expand('%:p:h')) . " blame -L <line1>,<line2> " . expand('%:t')), "\n")
@romainl
Copy link
Author

romainl commented Dec 14, 2019

@Konfect, fixed, thanks.

@axvr
Copy link

axvr commented Dec 26, 2019

IDEA: make it possible to pass an optional argument:

:GB HEAD~6

This has been working well for me.

command! -nargs=? -range GB echo join(systemlist("git -C " . shellescape(expand('%:p:h')) . " blame -L <line1>,<line2> <args> -- " . expand('%:t')), "\n")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment