Last active
June 21, 2017 19:05
-
-
Save merrilymeredith/7258c2f6d562918d1a48bedbed311778 to your computer and use it in GitHub Desktop.
g<C-]> improvement with ltag
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" 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