Reputation: 966
I'm using tmux + vim. Unlike vim split window, whenever I move focus to a different pane in tmux, the line highlight does not turn off like the following picture.
The red lines are the cursor lines and I moved the focus to the bottom tmux pane but the top pane vim cursor line still has highlight.
I would like to turn off the cursor line highlight when I leave the pane in tmux and only have highlight line for the current tmux pane. Does anyone know how to do that?
My vim setting for the line highlight is
""""""""""""""""""""""""""""""""""""
" Cursor line highlight
hi CursorLine cterm=NONE ctermbg=darkred guibg=darkred
hi CursorColumn cterm=NONE ctermbg=darkred guibg=darkred
" hlight current line current window only
augroup CursorLine
au!
au VimEnter,WinEnter,BufWinEnter * setlocal cursorline
au WinLeave * setlocal nocursorline
augroup END
""""""""""""""""""""""""""""""""""""
====== EDIT 1 ======
au VimEnter,WinEnter,BufWinEnter,FocusGained,CmdwinEnter * setlocal cursorline
au WinLeave,FocusLost,CmdwinLeave * setlocal nocursorline
Also doesn't work.
====================
Upvotes: 2
Views: 3214
Reputation: 24812
If you're using iTerm2 you can use sjl/vitality.vim plugin which should work(ie restore FocusLost
/FocusGained
functionality) out of the box (according to the README, I can't try it out).
The akracun/vitality.vim fork provides the functionality for other terminals (xterm/uxterm according to the commit logs, though it works flawlessly on gnome-term for me).
Starting from tmux 1.9a you'll need to :
set -g focus-events on
to your .tmux.conflet g:vitality_tmux_can_focus = 1
to your .vimrcThen
au VimEnter,WinEnter,BufWinEnter,FocusGained,CmdwinEnter * setlocal cursorline
au WinLeave,FocusLost,CmdwinLeave * setlocal nocursorline
should work as expected
Upvotes: 2