Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I make vim highlight the current line on only the active buffer?

Tags:

vim

I have set cursorline in my vimrc. Is there any way to make vim highlight only the current line in the active buffer instead of all buffers?

like image 774
Eric M. Avatar asked Aug 18 '12 09:08

Eric M.


1 Answers

The problem with the BufEnter / BufLeave hooks used in Zsolt's answer is that they don't fire when moving to an adjacent window that displays the same buffer. I have used the following successfully:

augroup CursorLine
    au!
    au VimEnter,WinEnter,BufWinEnter * setlocal cursorline
    au WinLeave * setlocal nocursorline
augroup END
like image 64
Ingo Karkat Avatar answered Oct 31 '22 16:10

Ingo Karkat