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

35

9

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?

jordelver

Posted 2013-02-28T16:23:32.530

Reputation: 1 781

Answers

44

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('')

Ingo Karkat

Posted 2013-02-28T16:23:32.530

Reputation: 19 513

Seems outdated as set signcolumn=yes does the trick without shenanigans. – cprn – 2018-10-22T12:43:11.207

1@cprn: You're right; I've added that to my answer. Thanks! – Ingo Karkat – 2018-10-22T14:44:59.723

Thank you as well, removing my answer from the bottom then. Cheers! – cprn – 2018-10-22T17:20:30.640

14To 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 – 2013-03-07T01:40:24.297

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"

wjv

Posted 2013-02-28T16:23:32.530

Reputation: 691

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 – 2016-04-11T06:17:45.503

5btw, for me it was set signcolumn=yes without the quotes – tam5 – 2017-12-31T19:56:37.860

Thanks, that option must of been added after this question was posted. Useful to know though. – jordelver – 2014-03-14T11:57:43.417

1Indeed, it seems that the commit which added it was made on 14 March 2013 — exactly two weeks after your question! – wjv – 2014-03-14T19:05:25.523

6

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

innaM

Posted 2013-02-28T16:23:32.530

Reputation: 9 208

Error detected while processing BufReadPost Auto commands for "*": E518: Unknown option: signcolumn=yes – brandones – 2017-06-18T19:21:01.513

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 – 2017-09-07T15:59:30.093