When jumping to a tag it seems that ":" are ignored for the purpose of "under the cursor" (I'm assuming it's "word" "under the cursor"). For example if I want to jump to

myTree::Node something

I want proper Node definition to be identified (I did run ctags with +q), rather than the plethora of system library nodes I have tagged.

I thought I worked around this using

vnoremap ak <ESC>?[^a-zA-Z0-9:_]<CR>lv/[^a-zA-Z0-9:_]<CR>h

so I could easily mark the full qualifier when I'm on top of it, then ctrl-] and g] work nicely.

Unfortunately it seems the ctrl-w commands ignore the mark, and still use only "Node" in the above example for the matching.

I want <ctrl-w> <ctrl-]> to work as expected when the full qualifier is marked. Even better, I would like to change the definition of "under the cursor" or "word", or the used text object to include ":" (this will probably only annoy in Python anyway) so I won't even need my mapping. Is this possible, and if so, how?

  • 1
    You might could adjust iskeyword, but that has far-reaching effects – D. Ben Knoble Nov 12 '19 at 17:24
  • @D.BenKnoble After reading a bit, I'm trying to avoid that for now, but you might add that as an answer anyway, in case that's the only solution. Perhaps somehow wrap it in a command that rebinds it and then rebinds it back or the like? – kabanus Nov 13 '19 at 6:48

As a workaround, I remapped <C-w><C-]>. I am still looking for other, more "holistic" solutions. Added these lines to my .vimrc:

noremap <C-w><C-]> :split<bar>normal vak<CR>g<C-]>
noremap <C-w>] :normal vak<CR>g<C-]>

which conveniently mark said custom text object, and jumps to it if there is a single definition, or opens a list of matches otherwise. The two variants either split the window or jump in the same one.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.