How to navigate multiple ctags matches in Vim?

前端 未结 4 1134
暖寄归人
暖寄归人 2021-01-30 16:11

I\'m using Ctrl-] in Vim to navigate using Ctags. How do I navigate to alternate file if there are multiple matches?

Ex. something.publish

4条回答
  •  礼貌的吻别
    2021-01-30 16:29

    ltag

    ltag the_tag_name
    lopen
    

    opens a location window with the tag matches.

    This is specially powerful with regular expression tag searches:

    ltag /tag_na
    lopen
    

    which will list all tags that contain the string tag_na (thus including the_tag_name).

    You can then further search inside the location list, before hitting enter to jump to the tag.

    To use it for the word under the cursor, you might want to define the map:

    nnoremap l exec("ltag ".expand(""))
    

    Then, if you are a tab maniac like me:

    command! -nargs=1 Ltag silent ltag  | execute "normal \" | tab lopen
    

    will open a new tab with the location list and all the matches, instead of jumping to the tab directly:

    :Ltag /my_struct
    

提交回复
热议问题