Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to hide cursor line when focus in on other window in vim

Tags:

vim

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

like image 249
deven98602 Avatar asked Dec 28 '12 11:12

deven98602


2 Answers

Essentially, it's 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 occasionally, you may want to define exceptions (i.e. permanently on or off) for certain windows. That's where my CursorLineCurrentWindow plugin may be helpful.

like image 141
Ingo Karkat Avatar answered Nov 07 '22 02:11

Ingo Karkat


It sounds like you want the cursorline on when entering a vim buffer and off when leaving it. These commands in the vimrc file will achieve this:

autocmd BufEnter * set cursorline
autocmd BufLeave * set nocursorline
like image 43
FuzzyWuzzy Avatar answered Nov 07 '22 04:11

FuzzyWuzzy