How to automatically update tag file in vim?

后端 未结 7 652
南旧
南旧 2021-01-30 02:32

I use vim C++ tag file for navigation using Ctrl-]. The problem is whenever some file gets modified, the links are no longer valid and I have to re-run ctags and update the tag

7条回答
  •  攒了一身酷
    2021-01-30 03:10

    I already wrote a plugin to do all the hard job with ctags: Indexer.

    It provides painless automatic tags generation for the whole project(s) and keeps tags up-to-date. Tags is generated in background, so, you do not have to wait while ctags generates tags. You can use it independently or as an add-on for another plugin project.tar.gz.

    In the first way, you can declare your projects in ~/.indexer_files like this:

    [CoolProject]
    
    /home/user/cool_project
    
    [AnotherProject]
    option:ctags_params = "--languages=c++"
    
    /home/user/another_project/src
    /home/user/another_project/lib 
    

    And then, when you open any file from /home/user/cool_project , all this project will be indexed by ctags. When you open tags from another project, tags is generated for it too. Tags from different projects is never mixed. When you save file from project, tags is silently updated. You do not have to care about it, it just works.

    For detailed information, see the article: Vim: convenient code navigation for your projects, which explains the usage of Indexer + Vimprj thoroughly.

    It is successfully tested on Vim 7.3, on the following systems:

    • Archlinux

    • Ubuntu 10.4

    • Windows XP

    • Mac OS X Lion

提交回复
热议问题