How can I make the Sign Column show up all the time even if no Signs have been added to it?

I've just added the Git Gutter plugin for Vim which shows lines added/modified/deleted according to git diff. It uses the Sign Column to show characters next to each line.

At the moment the column appears on save, which is quite jarring. I'd prefer the column to always show, even if empty.

How can I make Sign Column always visible?


Solution 1:

Starting with Vim 7.4.2201, you can do:

:set signcolumn=yes

Cp. :help 'signcolumn'. For older Vim versions, you have to define a dummy sign and place it into the current buffer:

:sign define dummy
:execute 'sign place 9999 line=1 name=dummy buffer=' . bufnr('')

Solution 2:

For vim-gitgutter specifically, you can also set the following variable in your ~/.vimrc:

let g:gitgutter_sign_column_always = 1

UPDATE

The plugin will now issue a warning to remove the above line and instead use:

set signcolumn="yes"

Solution 3:

While the little dance defining a sign and placing it works ok, a more elegant alternative that works well for me is:

autocmd BufRead,BufNewFile * setlocal signcolumn=yes

And if there are certain filetypes that are not supposed to have the column:

autocmd FileType tagbar,nerdtree setlocal signcolumn=no