Skip to content

Instantly share code, notes, and snippets.

@spiiph
Created September 10, 2012 14:47
Show Gist options
  • Save spiiph/3691241 to your computer and use it in GitHub Desktop.
Save spiiph/3691241 to your computer and use it in GitHub Desktop.
Some examples using tags to find files
" Improved goto file {{{2
" echo the full path of the file name under the cursor
nmap <silent> <Leader>gf :call <SID>FindFilesByTag(expand("<cfile>"))<CR>
" go to the file name under the cursor
nnoremap <expr> gf empty(taglist(fnamemodify(expand('<cfile>'), ":t"))) ? "gf" : ":tj <C-r><C-f><CR>"
nnoremap <expr> <C-w>f empty(taglist(fnamemodify(expand('<cfile>'), ":t"))) ? "\<C-w>f" : ":stj <C-r><C-f><CR>"
function! s:FindFilesByTag(file) " {{{2
for f in taglist(expand(a:file))
echo f["filename"]
endfor
endfunc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment