Skip to content

Instantly share code, notes, and snippets.

@merrilymeredith
Last active June 21, 2017 19:05
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 merrilymeredith/7258c2f6d562918d1a48bedbed311778 to your computer and use it in GitHub Desktop.
Save merrilymeredith/7258c2f6d562918d1a48bedbed311778 to your computer and use it in GitHub Desktop.
g<C-]> improvement with ltag
" The default behind g<C-]> is `tselect`, which gives you an awkward prompt that
" is awful if you get more than a page of results. This switches that out for
" `ltag`, which loads the location list, allowing LL commands and shortcuts.
" Use ltag instead of tselect
nmap g<C-]> :call Ltag(expand('<cword>'))<CR>
" Function wrapping to run ltag then lopen, and abort if ltag finds nothing
func! Ltag(term) abort
exe "ltag " . a:term
lopen
endfunc
" Optional: Simplify noisy ltag output in the quickfix window
autocmd BufReadPost quickfix
\ if w:quickfix_title =~ '^:ltag' |
\ setl modifiable |
\ silent exe ':%s/\^\\V\s*\|\\\$|.*//g' |
\ setl nomodifiable |
\ endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment