From eb1ccae17e60a0f5941d52271dae3a4fa8f58002 Mon Sep 17 00:00:00 2001 From: Taybin Rutkin Date: Thu, 3 Mar 2011 16:55:00 -0500 Subject: [PATCH] Add g:tagbar_autofocus option to always move cursor to tagbar window when it opens --- plugin/tagbar.vim | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/plugin/tagbar.vim b/plugin/tagbar.vim index bf1c5e4..f0dc879 100644 --- a/plugin/tagbar.vim +++ b/plugin/tagbar.vim @@ -54,6 +54,10 @@ if !exists('g:tagbar_autoclose') let g:tagbar_autoclose = 0 endif +if !exists('g:tagbar_autofocus') + let g:tagbar_autofocus = 0 +endif + if !exists('g:tagbar_sort') let g:tagbar_sort = 1 endif @@ -909,9 +913,9 @@ function! s:OpenWindow(autoclose) execute 'wincmd p' - " Jump back to the tagbar window if autoclose is set. Can't just stay in - " it since it wouldn't trigger the update event - if g:tagbar_autoclose || a:autoclose + " Jump back to the tagbar window if autoclose or autofocus is set. Can't + " just stay in it since it wouldn't trigger the update event + if g:tagbar_autoclose || a:autoclose || g:tagbar_autofocus let tagbarwinnr = bufwinnr('__Tagbar__') execute tagbarwinnr . 'wincmd w' endif