How do I see git diff changes in the Vim sign column with vim-gitgutter?
Answer
:GitGutterToggle
Explanation
vim-gitgutter is a plugin that shows git diff markers in the sign column (the narrow column to the left of line numbers). It gives you an instant visual indicator of which lines have been added, modified, or removed compared to the last git commit.
How it works
vim-gitgutter runs git diff in the background and places signs next to lines that differ from the index. A + sign indicates an added line, a ~ indicates a modified line, and a - indicates a removed line. The signs update automatically as you edit, with a configurable delay (default 100ms via updatetime).
The plugin is enabled by default after installation. Running :GitGutterToggle toggles the sign display on and off. You can also use :GitGutterEnable and :GitGutterDisable for explicit control.
Beyond just showing signs, vim-gitgutter provides hunk navigation and staging. You can jump between changed hunks and even stage or undo individual hunks without leaving Vim.
Example
Install the plugin and add useful mappings to your .vimrc:
Plug 'airblade/vim-gitgutter'
nmap ]c <Plug>(GitGutterNextHunk)
nmap [c <Plug>(GitGutterPrevHunk)
nmap <leader>hs <Plug>(GitGutterStageHunk)
nmap <leader>hu <Plug>(GitGutterUndoHunk)
nmap <leader>hp <Plug>(GitGutterPreviewHunk)
With these mappings, ]c and [c jump to the next and previous changed hunk. <leader>hs stages the hunk under the cursor (like a partial git add), <leader>hu reverts the hunk to its committed state, and <leader>hp opens a preview window showing the diff for that hunk. This workflow lets you build precise commits without touching the command line.