majutsushi/tagbar — Issue #63: [interface feature request] opening folds with <CR> (with patch)
Author: naquad
Created: 2012-02-16 14:02:48+00:00
State: open

Hi.

Your plugin rocks! I've been using taglist, but it doesn't have a chance against Tagbar.
What I've found confusing is that you need to press o to toggle fold, I wanted to use which seems to be more convinient.

So thats what I did in JumpToTag function:

diff --git a/autoload/tagbar.vim b/autoload/tagbar.vim
index 9b9de45..2eb67f3 100644
--- a/autoload/tagbar.vim
+++ b/autoload/tagbar.vim
@@ -2520,12 +2520,13 @@ endfunction
function! s:JumpToTag(stay_in_tagbar)
let taginfo = s:GetTagInfo(line('.'), 1)

- let autoclose = w:autoclose
-
- if empty(taginfo) || has_key(taginfo, 'numtags')
- return
+ if empty(taginfo) || has_key(taginfo, 'numtags') || taginfo.isFoldable()
+ return s:ToggleFold()
+ elseif taginfo.isKindheader()
+ return taginfo.toggleFold()
endif

+ let autoclose = w:autoclose
let tagbarwinnr = winnr()

" This elaborate construct will try to switch to the correct

I didn't test much, but it works for C++.