Как перейти к правильному определению метода, когда совпадают несколько тегов?

1703
Felix

Я попытался сгенерировать файл тега с помощью:

ctags -R * −−java−kinds=+mc 

Но когда найдено более одного совпадения, ctrl +] всегда переходит к неверному определению метода в другом классе.

Я знаю, что могу использовать: tjump, чтобы выбрать, если есть несколько вариантов. Но я надеюсь, что есть лучшее решение (если есть)?

2
Посмотрите на `: help tag-priority` Flimm 10 лет назад 0

2 ответа на вопрос

7
Ingo Karkat

In such cases, I'd recommend using g CTRL-] instead of CTRL-]. Like :tjump, this will list all available tag matches and query you instead of jumping to the first.

To make this the default, you can use this mapping:

:nnoremap <C-]> g<C-]> 
Привет, у вас есть какие-либо подсказки по [этой проблеме] (https://superuser.com/questions/1269284/vim-does-not-jump-to-correct-line-of-tag-chosen-in-tselect-match -список)? georgexsh 6 лет назад 0
так что я думаю, что `ctags` не может знать об этом. Поэтому мы должны перечислить их, и мы делаем выбор. daixtr 5 лет назад 0
0
romainl

Neither ctags nor vim have the ability to guess what the correct tag is and there's no way around that beside :tjump or :tselect. :tag has a priority mechanism that you can read about in the doc but that's still pretty dumb.

Cscope is a little smarter but not that much.

Given that situation, listing possible targets for you to choose is the only sane and practical approach.