VIM tag path for multiple projects

I recently started using ctags for my projects. I currently have the following setup:

root/tags [contains all non-static tags] root/foo/tags [contains static tags for the foo directory] root/bar/tags [static] root/something/else/tags [etc.] ... 

I can set tags=./tags,tags,/path/to/root/tags , and everything works fine.

However, my problem is that I work on several projects at once, so I have, for example, /path/to/root1 , /path/to/root2 and /path/to/root3 all at once. I would not manually set tags every time I open a file; is there any way i can have tags for /path/to/rootX based on the file i am editing? (i.e. if I edit /path/to/root3/foo/xc , use tags in root3/tags ?

In my case, all my projects have a common parent directory; I really want something like:

 set tags=./tags,tags,substitute("%:p:h", "\(^\/path\/to\/.*/\).*$", "\1", "") 

but i cant get the right vimfu to get it working.

EDIT: I just realized that this would not work; I can not write to root* . Instead, I would like to save my main ctags file to ~/ctags/root*/tags , where there is a 1: 1 mapping between the ~/ctags/ and /path/to/ subdirectories [For those who may be interested, these are dynamic views ClearCase UCM; neither /view/XXX/ nor /view/XXX/vobs/ can be overwritten)

+4
source share
1 answer

If you want to:

 set tags=./tags,tags,substitute("%:p:h", "\(^\/path\/to\/.*/\).*$", "\1", "") 

Try:

 let &tags = './tags,tags,' . substitute(expand("%:p:h"), "\(^\/path\/to\/.*/\).*$", "\1", "") 

There is no extension in the command :set . Also, "%: p: h" will not automatically expand, so use expand() . Cm:

 :help :let-option :help expand() 
+2
source

All Articles