9

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

suppie
  • 1,087
  • 8
  • 10

1 Answers1

15

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-]>
Peter Rincker
  • 43,539
  • 9
  • 74
  • 101
  • thanks a lot.. that solved it.. mapping to g worked. put it in vimrc – suppie Oct 04 '11 at 08:54
  • how can you also map + left-mouse click to use behavior(2) instead of behavior(1)? Could I simply map tag to tjump? – NHDaly Jun 05 '13 at 15:27
  • `nnoremap g`. However I recommend using keyboard as it is the vim way. – Peter Rincker Jun 05 '13 at 15:31
  • I have trouble seeing how behavior(1) is useful in all but very rare occasions, in which case it's better to just press `1` rather than struggle to remember to prefix the command with `g`. Hence, unless someone convinces me otherwise, I won't bother with `[nv]noremove g ` in my config – matvore Dec 03 '20 at 04:01