Skip to content

Instantly share code, notes, and snippets.

@scrooloose
Created October 10, 2009 02:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scrooloose/206525 to your computer and use it in GitHub Desktop.
Save scrooloose/206525 to your computer and use it in GitHub Desktop.
add a :Tsearch command to open a :cwindow like list of matching tags
command -nargs=1 -complete=tag Tsearch call <SID>Tsearch(<f-args>)
"search for tags using the given search string, list them in a new window,
"user can hit enter on a tag to jump to it
function! s:Tsearch(str)
botright 10 new
let b:taglist = taglist(a:str)
for i in range(0, len(b:taglist)-1)
let next = b:taglist[i]
let text = next['name'] . '.....' . next['filename']
call setline(i+1, text)
endfor
syn match function #^.*\.\.\.\.\.#he=e-5
nnoremap <cr> :call <SID>JumpToTag()<cr>
set buftype=nofile
endfunction
"jump to the tag under the cursor
function! s:JumpToTag()
let tag = b:taglist[line(".")-1]
bdelete!
exec 'edit ' . tag['filename']
exec 'silent' . tag['cmd']
endfunction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment