Making the active window in vim more obvious

colorsvim

My workspace is normally one very big xterm with vim, split into six or more buffers. It would be really helpful if it were more obvious which one was the active buffer. Right now I'm using the presence of line numbers for this:

augroup BgHighlight
    autocmd!
    autocmd WinEnter * set number
    autocmd WinLeave * set nonumber
augroup END

but this means that when I change buffers my code jumps left or right, which is annoying. Plus, I'd like to be able to see which is line 94 even in an inactive buffer. So is there any way of changing the colours of the line numbers in the active buffer?

Best Answer

Following your template, you could vary different properties, such as colorcolumn:

augroup BgHighlight
    autocmd!
    autocmd WinEnter * set colorcolumn=80
    autocmd WinLeave * set colorcolumn=0
augroup END

This will color column 80 on your current window, while disabling it on the others. It's a bit less jarring than setting/unsetting line numbers.

An even less intrusive option, if you are used to highlighting the current line (set cul), is to do:

augroup BgHighlight
    autocmd!
    autocmd WinEnter * set cul
    autocmd WinLeave * set nocul
augroup END

It all comes down to your usage and what you're willing to put up with.