" " cursorline_current.vim: Apply 'cursorline' only in normal mode in the active " window. " " Author: Tom Ryder " License: Same as Vim itself " if exists('loaded_cursorline_current') || &compatible || v:version < 700 finish endif let loaded_cursorline_current = 1 augroup cursorline_current autocmd! " On opening Vim, we might have to get initial windows into the right state. " Run the hook for leaving windows on every window, and then move back to " the first window and run the hook for entering a window. " autocmd VimEnter * \ tabdo windo doautocmd WinLeave autocmd VimEnter * \ tabfirst | 1 wincmd w | doautocmd WinEnter " On entering a buffer, the Vim application gaining focus, leaving insert " mode, or entering a window, set the local value of the 'cursorline' option " to the same as the global value, to correspond with an active state. " autocmd BufEnter,FocusGained,InsertLeave,WinEnter * \ let &l:cursorline = &g:cursorline " On leaving a buffer, the Vim application window losing focus, entering " insert mode, or leaving a window, turn off the 'cursorline' option for the " linked window, so that if it's on, it will only be in the active one. " autocmd BufLeave,FocusGained,InsertEnter,WinLeave * \ let &l:cursorline = 0 augroup END