On 2007-03-07, "A.J.Mechelynck" <[EMAIL PROTECTED]> wrote: > Gary Johnson wrote: > > On 2007-03-07, Zarko Coklin <[EMAIL PROTECTED]> wrote: > >> Hi all! > >> > >> I am trying to automate my Vim setup as much as > >> possible. On my PC I have 2 directories for 2 > >> different releases. > >> > >> C:\Code_Rel1 > >> C:\Code_Rel2 > >> > >> At a very top level in each of these directories I > >> have ctags files. How can I setup Vim so that it > >> sources right ctags file depending from I started Vim. > >> For example, if I go under Code_Rel1 and in Windows > >> use right click to open file in one of subdirectories, > >> ctags should be picked up from C:\Code_Rel1 and not > >> from C:\Code_Rel2. > >> > >> Hard coding path to ctags in .vimrc is not an option, > >> cause it will not work well if I right-click to open > >> file from another release directory. > >> > >> Any thoughts on how this can be achieved? > > > > If you don't mind adding a command to your .vimrc for each ctags > > file, you could do this: > > > > au BufRead,BufNewFile C:/Code_Rel1/* set tags=C:/Code_Rel1/tags > > au BufRead,BufNewFile C:/Code_Rel2/* set tags=C:/Code_Rel2/tags > > > > HTH, > > Gary > > > > ...and if the directory trees can have more than one level, then use instead > > au BufRead,BufNewFile C:/CodeRel1/**/* > \ setlocal tags=C:/CodeRel1/tags > au BufRead,BufNewFile C:/CodeRel2/**/* > \ setlocal tags=C:/CodeRel2/tags > etc. > > Notice the use of ":setlocal" to avoid clobbering the 'tags' setting for > other windows opened in the same Vim instance.
Thanks for pointing out the setlocal issue--I had forgotten that 'tags' could be made local. However, the **/* is not necessary. The pattern "C:/Code_Rel1/*" will match any file under the C:/Code_Rel1 directory, including, for example, C:/Code_Rel1/foo/bar/thingy.txt. Regards, Gary -- Gary Johnson | Agilent Technologies [EMAIL PROTECTED] | Mobile Broadband Division | Spokane, Washington, USA