Shell diff Neovim Vim Git gitgutter
Need help with vim-gitgutter?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.


A Vim plugin which shows git diff markers in the sign column and stages/previews/undoes hunks and partial hunks.

6.7K Stars 257 Forks MIT License 729 Commits 3 Opened issues

Services available

Need anything else?


A Vim plugin which shows a git diff in the sign column. It shows which lines have been added, modified, or removed. You can also preview, stage, and undo individual hunks; and stage partial hunks. The plugin also provides a hunk text object.

The signs are always up to date and the plugin never saves your buffer.

The name "gitgutter" comes from the Sublime Text 3 plugin which inspired this in 2013.


  • Shows signs for added, modified, and removed lines.
  • Runs the diffs asynchronously where possible.
  • Ensures signs are always up to date.
  • Never saves the buffer.
  • Quick jumping between blocks of changed lines ("hunks").
  • Stage/undo/preview individual hunks.
  • Previews highlight intra-line changes.
  • Stage partial hunks.
  • Provides a hunk text object.
  • Diffs against index (default) or any commit.
  • Allows folding all unchanged text.
  • Provides fold text showing whether folded lines have been changed.
  • Can load all hunk locations into quickfix list or the current window's location list.
  • Handles line endings correctly, even with repos that do CRLF conversion.
  • Optional line highlighting.
  • Optional line number highlighting. (Only available in Neovim 0.3.2 or higher)
  • Fully customisable (signs, sign column, line (number) highlights, mappings, extra git-diff arguments, etc).
  • Can be toggled on/off, globally or per buffer.
  • Preserves signs from other plugins.
  • Easy to integrate diff stats into status line; built-in integration with vim-airline.
  • Works with fish shell (in addition to the usual shells).


  • Supports git only. If you work with other version control systems, I recommend vim-signify.
  • Relies on the
    event. If your terminal doesn't report focus events, either use something like Terminus or set
    let g:gitgutter_terminal_reports_focus=0
    . For tmux,
    set -g focus-events on
    in your tmux.conf.


Compatible back to Vim 7.4, and probably 7.3.



In the screenshot above you can see:

  • Lines 183-184 are new.
  • Lines 186-187 have been modified.
  • The preview for the modified lines highlights changed regions within the line.


Install using your favourite package manager, or use Vim's built-in package support.


mkdir -p ~/.vim/pack/airblade/start
cd ~/.vim/pack/airblade/start
git clone
vim -u NONE -c "helptags vim-gitgutter/doc" -c q


mkdir -p ~/.config/nvim/pack/airblade/start
cd ~/.config/nvim/pack/airblade/start
git clone
nvim -u NONE -c "helptags vim-gitgutter/doc" -c q


I recommend configuring vim-gitgutter with the full path to your git executable. For example:

let g:gitgutter_git_executable = 'C:\Program Files\Git\bin\git.exe'

This is to avoid a problem which occurs if you have file named

(i.e. with any extension in
) in your current folder.
prioritises the current folder over folders in
and will try to execute your file instead of the

Getting started

When you make a change to a file tracked by git, the diff markers should appear automatically. The delay is governed by vim's

option; the default value is
, i.e. 4 seconds, but I suggest reducing it to around 100ms (add
set updatetime=100
to your vimrc). Note
also controls the delay before vim writes its swap file (see
:help updatetime

You can jump between hunks with

. You can preview, stage, and undo hunks with
, and

You cannot unstage a staged hunk.

After updating the signs, the plugin fires the

User autocommand.

After staging a hunk or part of a hunk, the plugin fires the

User autocommand.


You can explicitly turn vim-gitgutter off and on (defaults to on):

  • turn off with
  • turn on with
  • toggle with

To toggle vim-gitgutter per buffer:

  • turn off with
  • turn on with
  • toggle with

You can turn the signs on and off (defaults to on):

  • turn on with
  • turn off with
  • toggle with

And you can turn line highlighting on and off (defaults to off):

  • turn on with
  • turn off with
  • toggle with

Note that if you have line highlighting on and signs off, you will have an empty sign column – more accurately, a sign column with invisible signs. This is because line highlighting requires signs and Vim/NeoVim always shows the sign column when there are signs even if the signs are invisible.

With Neovim 0.3.2 or higher, you can turn line number highlighting on and off (defaults to off):

  • turn on with
  • turn off with
  • toggle with

The same caveat applies to line number highlighting as to line highlighting just above.

If you switch off both line highlighting and signs, you won't see the sign column.

In older Vims (pre 8.1.0614 / Neovim 0.4.0) vim-gitgutter will suppress the signs when a file has more than 500 changes, to avoid slowing down the UI. As soon as the number of changes falls below the limit vim-gitgutter will show the signs again. You can configure the threshold with:

let g:gitgutter_max_signs = 500  " default value (Vim < 8.1.0614, Neovim < 0.4.0)
let g:gitgutter_max_signs = -1   " default value (otherwise)

You can also remove the limit by setting

g:gitgutter_max_signs = -1


You can jump between hunks:

  • jump to next hunk (change):
  • jump to previous hunk (change):

Both of those take a preceding count.

To set your own mappings for these, for example

nmap ]h (GitGutterNextHunk)
nmap [h (GitGutterPrevHunk)

When you jump between hunks, a message like

Hunk 4 of 11
is shown on the command line. If you want to turn the message off, you can use:
let g:gitgutter_show_msg_on_hunk_jumping = 0

You can load all your hunks into the quickfix list with

. Note this ignores any unsaved changes in your buffers. If the option
is set, this command will load hunks into the current window's location list instead. Use
) to open the quickfix / location list or add a custom command like this:
command! Gqf GitGutterQuickFix | copen

You can stage or undo an individual hunk when your cursor is in it:

  • stage the hunk with
  • undo it with

To stage part of an additions-only hunk by:

  • either visually selecting the part you want and staging with your mapping, e.g.
  • or using a range with the
    command, e.g.

To stage part of any hunk:

  • preview the hunk, e.g.
  • move to the preview window, e.g.
    :wincmd P
  • delete the lines you do not want to stage;
  • stage the remaining lines: either write (
    ) the window or stage via

Note the above workflow is not possible if you have opted in to preview hunks with Vim's popup windows.

See the FAQ if you want to unstage staged changes.


command will work with both these if you install repeat.vim.

To set your own mappings for these, for example if you prefer

-based maps:
nmap ghs (GitGutterStageHunk)
nmap ghu (GitGutterUndoHunk)

And you can preview a hunk's changes with

. The location of the preview window is configured with
). You can of course change this mapping, e.g:
nmap ghp (GitGutterPreviewHunk)

A hunk text object is provided which works in visual and operator-pending modes.

  • ic
    operates on all lines in the current hunk.
  • ac
    operates on all lines in the current hunk and any trailing empty lines.

To re-map these, for example to

omap ih (GitGutterTextObjectInnerPending)
omap ah (GitGutterTextObjectOuterPending)
xmap ih (GitGutterTextObjectInnerVisual)
xmap ah (GitGutterTextObjectOuterVisual)

If you don't want vim-gitgutter to set up any mappings at all, use this:

let g:gitgutter_map_keys = 0

Finally, you can force vim-gitgutter to update its signs across all visible buffers with


See the customisation section below for how to change the defaults.


Use the

command to fold all unchanged lines, leaving just the hunks visible. Use
to unfold 3 lines of context above and below a hunk.


a second time to restore the previous view.


to augment the default
with an indicator of whether the folded lines have been changed.
set foldtext=gitgutter#fold#foldtext()

For a closed fold with changed lines:

Default foldtext():         +-- 45 lines: abcdef
gitgutter#fold#foldtext():  +-- 45 lines (*): abcdef

You can use

in your own
expression to find out whether the folded lines have been changed.

Status line

Call the

function from your status line to get a list of counts of added, modified, and removed lines in the current buffer. For example:
" Your vimrc
function! GitStatus()
  let [a,m,r] = GitGutterGetHunkSummary()
  return printf('+%d ~%d -%d', a, m, r)
set statusline+=%{GitStatus()}


You can customise:

  • The sign column's colours
  • Whether or not the sign column is shown when there aren't any signs (defaults to no)
  • How to handle non-gitgutter signs
  • The signs' colours and symbols
  • Line highlights
  • Whether the diff is relative to the index (default) or working tree.
  • The base of the diff
  • Extra arguments for
    when running
    git diff
  • Extra arguments for
    git diff
  • Key mappings
  • Whether vim-gitgutter is on initially (defaults to on)
  • Whether signs are shown (defaults to yes)
  • Whether line highlighting is on initially (defaults to off)
  • Whether line number highlighting is on initially (defaults to off)
  • Whether vim-gitgutter runs asynchronously (defaults to yes)
  • Whether to clobber or preserve non-gitgutter signs
  • The priority of gitgutter's signs.
  • Whether to use a floating/popup window for hunk previews
  • Whether to populate the quickfix list or a location list with all hunks

Please note that vim-gitgutter won't override any colours or highlights you've set in your colorscheme.

Sign column

Set the

highlight group to change the sign column's colour. For example:
" vim-gitgutter used to do this by default:
highlight! link SignColumn LineNr

" or you could do this: highlight SignColumn guibg=whatever ctermbg=whatever

By default the sign column will appear when there are signs to show and disappear when there aren't. To always have the sign column, add to your vimrc:

" Vim 7.4.2201
set signcolumn=yes

GitGutter can preserve or ignore non-gitgutter signs. For Vim v8.1.0614 and later you can set gitgutter's signs' priorities with

, so gitgutter defaults to clobbering other signs. For Neovim v0.4.0 and later you can set an expanding sign column so gitgutter again defaults to clobbering other signs. Otherwise, gitgutter defaults to preserving other signs. You can configure this with:
let g:gitgutter_sign_allow_clobber = 1

Signs' colours and symbols

If you or your colourscheme has defined

highlight groups, the plugin will use them for the signs' colours.

If you want the background colours to match the sign column, but don't want to update the

groups yourself, you can get the plugin to do it:
let g:gitgutter_set_sign_backgrounds = 1

If no

highlight groups exist, the plugin will check the
highlight groups. If their foreground colours differ the plugin will use them; if not, these colours will be used:
highlight GitGutterAdd    guifg=#009900 ctermfg=2
highlight GitGutterChange guifg=#bbbb00 ctermfg=3
highlight GitGutterDelete guifg=#ff2222 ctermfg=1

To customise the symbols, add the following to your

let g:gitgutter_sign_added = 'xx'
let g:gitgutter_sign_modified = 'yy'
let g:gitgutter_sign_removed = 'zz'
let g:gitgutter_sign_removed_first_line = '^^'
let g:gitgutter_sign_removed_above_and_below = '{'
let g:gitgutter_sign_modified_removed = 'ww'

Line highlights

Similarly to the signs' colours, set up the following highlight groups in your colorscheme or

GitGutterAddLine          " default: links to DiffAdd
GitGutterChangeLine       " default: links to DiffChange
GitGutterDeleteLine       " default: links to DiffDelete
GitGutterChangeDeleteLine " default: links to GitGutterChangeLineDefault, i.e. DiffChange

For example, in some colorschemes the

highlight group is easier to read than
. You could use it like this:
highlight link GitGutterChangeLine DiffText

Line number highlights

NOTE: This feature requires Neovim 0.3.2 or higher.

Similarly to the signs' colours, set up the following highlight groups in your colorscheme or

GitGutterAddLineNr          " default: links to CursorLineNr
GitGutterChangeLineNr       " default: links to CursorLineNr
GitGutterDeleteLineNr       " default: links to CursorLineNr
GitGutterChangeDeleteLineNr " default: links to CursorLineNr

Maybe you think

is a bit annoying. For example, you could use
for this:
highlight link GitGutterChangeLineNr Underlined

Whether the diff is relative to the index or working tree

By default diffs are relative to the index. How you can make them relative to the working tree:

let g:gitgutter_diff_relative_to = 'working_tree'

The base of the diff

By default buffers are diffed against the index. However you can diff against any commit by setting:

let g:gitgutter_diff_base = ''

If you are looking at a previous version of a file with Fugitive (e.g. via

), gitgutter sets the diff base to the parent of the current revision.

This setting is ignored when the diffs are relative to the working tree.

Extra arguments for
when running
git diff

If you want to pass extra arguments to

when running
git diff
, do so like this:
let g:gitgutter_git_args = '--git-dir-""'

Extra arguments for
git diff

If you want to pass extra arguments to

git diff
, for example to ignore whitespace, do so like this:
let g:gitgutter_diff_args = '-w'

Key mappings

To disable all key mappings:

let g:gitgutter_map_keys = 0

See above for configuring maps for hunk-jumping and staging/undoing.

Use a custom

If you use an alternative to grep, you can tell vim-gitgutter to use it here.

" Default:
let g:gitgutter_grep = 'grep'

To turn off vim-gitgutter by default


let g:gitgutter_enabled = 0
to your

To turn off signs by default


let g:gitgutter_signs = 0
to your

To turn on line highlighting by default


let g:gitgutter_highlight_lines = 1
to your

To turn on line number highlighting by default


let g:gitgutter_highlight_linenrs = 1
to your

To turn off asynchronous updates

By default diffs are run asynchronously. To run diffs synchronously instead:

let g:gitgutter_async = 0

To use floating/popup windows for hunk previews


let g:gitgutter_preview_win_floating = 1
to your
. Note that on Vim this prevents you staging (partial) hunks via the preview window.

To load all hunks into the current window's location list instead of the quickfix list


let g:gitgutter_use_location_list = 1
to your


Operate on every line in a hunk

You can map an operator to do whatever you want to every line in a hunk.

Let's say, for example, you want to remove trailing whitespace.

function! CleanUp(...)
  if a:0  " opfunc
    let [first, last] = [line("'["), line("']")]
    let [first, last] = [line("'")]
  for lnum in range(first, last)
    let line = getline(lnum)

" clean up the text, e.g.:
let line = substitute(line, '\s\+$', '', '')

call setline(lnum, line)

endfor endfunction

nmap x :set opfunc=CleanUp[email protected]

Then place your cursor in a hunk and type

(assuming a leader of

Alternatively you could place your cursor in a hunk, type

to select it, then
:call CleanUp()

Operate on every changed line in a file

You can write a command to do whatever you want to every changed line in a file.

function! GlobalChangedLines(ex_cmd)
  for hunk in GitGutterGetHunks()
    for lnum in range(hunk[2], hunk[2]+hunk[3]-1)
      let cursor = getcurpos()
      silent! execute lnum.a:ex_cmd
      call setpos('.', cursor)

command -nargs=1 Glines call GlobalChangedLines()

Let's say, for example, you want to remove trailing whitespace from all changed lines:

:Glines s/\s\+$//

Cycle through hunks in current buffer

This is like

but when it gets to the last hunk in the buffer it cycles around to the first.
function! GitGutterNextHunkCycle()
  let line = line('.')
  silent! GitGutterNextHunk
  if line('.') == line

Cycle through hunks in all buffers

You can use

to load all hunks into the quickfix list or the current window's location list.

Alternatively, given that

jump from one hunk to the next in the current buffer, you can use this code to jump to the next hunk no matter which buffer it's in.
function! NextHunkAllBuffers()
  let line = line('.')
  if line('.') != line

let bufnr = bufnr('') while 1 bnext if bufnr('') == bufnr return endif if !empty(GitGutterGetHunks()) 1 GitGutterNextHunk return endif endwhile endfunction

function! PrevHunkAllBuffers() let line = line('.') GitGutterPrevHunk if line('.') != line return endif

let bufnr = bufnr('') while 1 bprevious if bufnr('') == bufnr return endif if !empty(GitGutterGetHunks()) normal! G GitGutterPrevHunk return endif endwhile endfunction

nmap ]c :call NextHunkAllBuffers() nmap [c :call PrevHunkAllBuffers()


How can I turn off realtime updates?

Add this to your vim configuration (in an

" .vim/after/plugin/gitgutter.vim
autocmd! gitgutter CursorHold,CursorHoldI

I turned off realtime updates, how can I have signs updated when I save a file?

If you really want to update the signs when you save a file, add this to your vimrc:

autocmd BufWritePost * GitGutter

Why can't I unstage staged changes?

This plugin is for showing changes between the buffer and the index (and staging/undoing those changes). Unstaging a staged hunk would require showing changes between the index and HEAD, which is out of scope.

Why are the colours in the sign column weird?

Your colorscheme is configuring the

highlight group weirdly. Please see the section above on customising the sign column.

What happens if I also use another plugin which uses signs (e.g. Syntastic)?

You can configure whether GitGutter preserves or clobbers other signs using

. Set to
to clobber other signs (default on Vim >= 8.1.0614 and NeoVim >= 0.4.0) or
to preserve them.


When no signs are showing at all

Here are some things you can check:

  • Try adding
    let g:gitgutter_grep=''
    to your vimrc. If it works, the problem is grep producing non-plain output; e.g. ANSI escape codes or colours.
  • Verify
    :echo system("git --version")
  • Verify your git config is compatible with the version of git returned by the command above.
  • Verify your Vim supports signs (
    :echo has('signs')
    should give
  • Verify your file is being tracked by git and has unstaged changes. Check whether the plugin thinks git knows about your file:
    :echo b:gitgutter.path
    should show the path to the file in the repo.
  • Execute
    :sign place group=gitgutter
    ; you should see a list of signs.
    • If the signs are listed: this is a colorscheme / highlight problem. Compare
      :highlight GitGutterAdd
      :highlight SignColumn
    • If no signs are listed: the call to git-diff is probably failing. Add
      let g:gitgutter_log=1
      to your vimrc, restart, reproduce the problem, and look at the
      file in the plugin's directory.

When the whole file is marked as added

  • If you use zsh, and you set
    , make sure
    doesn't include the current directory.

When signs take a few seconds to appear

  • Try reducing
    , e.g.
    set updatetime=100
    . Note this also controls the delay before vim writes its swap file.

When signs don't update after focusing Vim

  • Your terminal probably isn't reporting focus events. Either try installing Terminus or set
    let g:gitgutter_terminal_reports_focus=0
    . For tmux, try
    set -g focus-events on
    in your tmux.conf.

Shameless Plug

If this plugin has helped you, or you'd like to learn more about Vim, why not check out this screencast I wrote for PeepCode:

This was one of PeepCode's all-time top three bestsellers and is now available at Pluralsight.

You can read reviews on my website.

Intellectual Property

Copyright Andrew Stewart, AirBlade Software Ltd. Released under the MIT licence.

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.