diff --git a/autoload/tagbar.vim b/autoload/tagbar.vim index 4d9dc61..2582999 100644 --- a/autoload/tagbar.vim +++ b/autoload/tagbar.vim @@ -3969,5 +3969,14 @@ function! tagbar#IsOpen() abort endif endfunction +" tagbar#jump() {{{2 +function! tagbar#jump() abort + if &filetype !=# 'tagbar' + " Not in tagbar window - ignore this function call + return + endif + call s:JumpToTag(1) +endfun + " Modeline {{{1 " vim: ts=8 sw=4 sts=4 et foldenable foldmethod=marker foldcolumn=1 diff --git a/doc/tagbar.txt b/doc/tagbar.txt index 3350a8f..47cbd49 100644 --- a/doc/tagbar.txt +++ b/doc/tagbar.txt @@ -318,6 +318,13 @@ COMMANDS *tagbar-commands* the file size limit. So if the file is written and needs to be processed again, this command will need to be re-executed. +:TagbarJump *:TagbarJump* + Jump to the tag under the cursor. This only works while the cursor is in + the tagbar window. This will leave the cursor in the tagbar window. It is + the same behavior as the |p| key mapping. + + This command will call the |tagbar#jump()| function. + ------------------------------------------------------------------------------ FUNCTIONS *tagbar-functions* @@ -360,6 +367,13 @@ FUNCTIONS *tagbar-functions* This function will return 1 if the tagbar window is open, else it will return 0. +*tagbar#jump()* + Jump to the tag under the cursor. This only works while the cursor is in + the tagbar window. This will leave the cursor in the tagbar window. It is + the same behavior as the |p| key mapping. + + This is the function called when using the |:TagbarJump| command. + ------------------------------------------------------------------------------ KEY MAPPINGS *tagbar-keys* diff --git a/plugin/tagbar.vim b/plugin/tagbar.vim index 68ef10f..c93077d 100644 --- a/plugin/tagbar.vim +++ b/plugin/tagbar.vim @@ -195,6 +195,8 @@ command! -nargs=? TagbarDebug call tagbar#debug#start_debug() command! -nargs=0 TagbarDebugEnd call tagbar#debug#stop_debug() command! -nargs=0 TagbarTogglePause call tagbar#toggle_pause() command! -nargs=0 TagbarForceUpdate call tagbar#ForceUpdate() +command! -nargs=0 TagbarJump call tagbar#jump() + " Modeline {{{1 " vim: ts=8 sw=4 sts=4 et foldenable foldmethod=marker foldcolumn=1