32

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?

39

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('')
  • 14
    To make it work in every new buffer you open, put both autocmd BufEnter * sign define dummy and autocmd BufEnter * execute 'sign place 9999 line=1 name=dummy buffer=' . bufnr('') in your vimrc. – akent Mar 7 '13 at 1:40
  • Seems outdated as set signcolumn=yes does the trick without shenanigans. – cprn Oct 22 '18 at 12:43
  • 1
    @cprn: You're right; I've added that to my answer. Thanks! – Ingo Karkat Oct 22 '18 at 14:44
  • Thank you as well, removing my answer from the bottom then. Cheers! – cprn Oct 22 '18 at 17:20
22

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"
  • Thanks, that option must of been added after this question was posted. Useful to know though. – jordelver Mar 14 '14 at 11:57
  • 1
    Indeed, it seems that the commit which added it was made on 14 March 2013 — exactly two weeks after your question! – wjv Mar 14 '14 at 19:05
  • While working on something else I recently poked around inside the GitGutter source, and I noticed that setting this variable forces the display of the sign column in exactly the same way as the accepted answer to this question — by setting a dummy sign. – wjv Apr 11 '16 at 6:17
  • 5
    btw, for me it was set signcolumn=yes without the quotes – tam5 Dec 31 '17 at 19:56
5

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
  • Error detected while processing BufReadPost Auto commands for "*": E518: Unknown option: signcolumn=yes – brandones Jun 18 '17 at 19:21
  • You need a newer version of vim, @brandonjones. I'm not sure when signcolumn was added, but it's not there in 7.2 and it's there in 8.0. I don't remember seeing it in 7.4, but it may be there. It's present in current versions of both Vim and Neovim. – Jim Stewart Sep 7 '17 at 15:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.