use :tjump instead of :tag vim on pressing ctrl-]

时光毁灭记忆、已成空白 提交于 2019-12-19 00:57:53

问题


in vim,
when i press ctrl-]

1) the usual behavior:
it goes to the first matching tag with the word under the cursor, after that we need to do :tjump separately to see a list of all matching tags and then jump to the desired tag.

2) what i want is:
vim should search the tag file,
if there are multiple matches, show me a list of all the matching tags
if there is one match, simply jump to the matching tag
(just like :tjump does)

this behavior(2) already happens when we use g-ctrl-], but i want it to happen with ctrl-]
i have seen behavior(2) using ctrl-] in some vims in some linuses.

please tell me how i can obtain behavior(2). in other words,
please tell me how i can make ctrl-] to behave like g-ctrl-] using .vimrc or whatever


回答1:


This will map <c-]> to g<c-]> for both normal and visual modes.

nnoremap <c-]> g<c-]>
vnoremap <c-]> g<c-]>

I suggest you map g<c-]> to <c-]>. In other words just swap the commands.

nnoremap g<c-]> <c-]>
vnoremap g<c-]> <c-]>


来源:https://stackoverflow.com/questions/7640663/use-tjump-instead-of-tag-vim-on-pressing-ctrl

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!