Vim field guide · dot-files

git_helpers (custom)

A small custom plugin (`.vim/plugin/git_helpers.vim`) that adds two git commands not covered by fugitive or fzf.vim.

The helpers run Git relative to the current file’s directory, so Vim’s working directory can be elsewhere. Save the buffer first. Git errors are shown in the message area; uncommitted lines report Not committed yet, and a log search with no matches reports No commits found for the search term. A GitHub origin produces a commit URL; other remotes show the commit hash.

:Blame — inline blame for the current line

:Blame

Prints the commit hash, author, subject, and GitHub URL for the line under the cursor — all in the Vim message area without leaving the file.

Example output:

Commit:
https://github.com/you/repo/commit/3b753cf8
 - 3b753cf (Marian P) fix: handle edge case in parser

How it differs from fugitive's :Git blame

:Blame (custom):Git blame (fugitive)
OutputInline message, stays in current bufferOpens a full interactive split
NavigationNoneFull commit browsing with <Enter>
SpeedInstantLoads full blame for the file

Use :Blame for a quick "who wrote this line?" check. Use :Git blame when you want to navigate the history.

:LogSearch / <leader>gs — find which commit introduced a line

Searches git log -S (the "pickaxe") for the exact text of the current line or visual selection, within the current file’s history. It shows the earliest matching commit URL or hash, followed by matching commit details.

Key / CommandAction
<leader>gsSearch for current line (normal mode)
<leader>gsSearch for selected text (visual mode)
:'<,'>LogSearchSame, via command

When to use it

Use <leader>gs when you want to know which commit first added or removed a specific string, rather than who last touched the line (that's :Blame). It is especially useful for tracking down when a particular value, function call, or bug was introduced.

Example: cursor on a line containing MAX_RETRIES = 5:

<leader>gs    →   finds the commit that first introduced that exact text

Relation to vim-rhubarb's :GBrowse

Both tools build a GitHub URL, but for different purposes:

ToolOpens / shows
:BlameCommit URL in the message area (stay in Vim)
:GBrowseOpens file / line / commit in the browser
<leader>gsCommit URL for the line's origin in the message area