:GB
:7,13GB
:,+5GB
:?foo?,$GB
:'<,'>GB
:%GB
:GB
:7,13GB
:,+5GB
:?foo?,$GB
:'<,'>GB
:%GB
| command! -range GB echo join(systemlist("git -C " . shellescape(expand('%:p:h')) . " blame -L <line1>,<line2> " . expand('%:t')), "\n") |
@kkoomen, that's a nice improvement, thanks.
If -C " . shellescape(expand('%:p:h')) is used, then correspondingly also expand('%:t') instead of '%'.
@Konfect, fixed, thanks.
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")
When using commands involving
gitI suggest to always use the-C <path>flag. Assuming I am in my home directory and I open~/projects/<name>/some/path/to/filethen this command will not work, because I'm running Vim outside of the Git repository.I suggest to use this command: