How to hide cursor line when focus is in another window in vim

In my vimrc file, I have this set cursorline option. I want to hide this line if this window is not in focus. Is there any way in vim to do this? See This screenshot

+4
source share
2 answers

In essence, these are just the following autocmds:

 augroup CursorLine au! au VimEnter * setlocal cursorline au WinEnter * setlocal cursorline au BufWinEnter * setlocal cursorline au WinLeave * setlocal nocursorline augroup END 

But sometimes you can define exceptions (that is, always on or off) for certain windows. This may be useful for my CursorLineCurrentWindow plugin .

+10
source

It looks like you want the mouse cursor to turn on when you enter the vim buffer and off when you leave it. These commands in the vimrc file accomplished this:

 autocmd BufEnter * set cursorline autocmd BufLeave * set nocursorline 
+1
source

All Articles