Source vimrc and use tags in a parent directory
Talk0
1,599pages on
this wiki
this wiki
Revision as of 07:19, May 4, 2011 by JohnBeckett (Talk | contribs)
Tip 571 Printable Monobook Previous Next
created September 30, 2003 · complexity basic · author mosh · version 5.7
" Source .../.vimrc and use .../tags in ancestor of source directory.
" useful when you have source tree eight fathom deep,
" an exercise in Vim loops.
let parent=1
let local_vimrc = ".vimrc"
let local_tags = "tags"
while parent <= 8
if filewritable(local_vimrc)
echomsg "sourcing " . local_vimrc
exe ":so " . local_vimrc
endif
let local_vimrc = "../". local_vimrc
let local_tags = "../". local_tags
exe ":set tags+=".local_tags
let parent = parent+1
" ToDo: stop at the root on windows and ~ on unix.
endwhile
unlet parent local_vimrc
See tip 727 for a way to handle local vimrc and tip 804 for upward tag searches.
References
Comments
There's a simpler way to do this for tags:
set tags+=tags;/
TO DO
Check above tip. It probably should be entirely replaced with the comment above.
Where is this documented in the :help?
:help 'tags' and :help file-searching
Should we delete this tip? Its content is handled in two separate tips. --Fritzophrenic 15:28, May 3, 2011 (UTC)
- I haven't had to worry about large trees of source for a while, and have forgotten what all the tags tricks do (although I've got some notes I took on it somewhere, and I'm sure this tip is the wrong approach). The current tip looks unhelpful to me. While mildly interesting, it is essentially an abuse of the system (do you really need a script which does what this appears to do?). I do not understand how VimTip727 has a way to handle local vimrc, but that doesn't matter. We could just replace this with a redirect to Single tags file for a source tree (and I would handle the associated change to the tip number). Is the first comment worth transferring to the target tip? JohnBeckett 07:19, May 4, 2011 (UTC)