History Report a problem
Article Edit this page Discussion

Source vimrc and use tags in a parent directory

From Vim Tips Wiki

Jump to: navigation, search
 

Tip 571Previous TipNext Tip

Created: September 30, 2003 Complexity: basic Author: mosh Minimum version: 5.7 Karma: 3/2 Imported from: Tip#571


" 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.

[edit] References

[edit] 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.


Rate this article:

Share this article:

Hubs Highlights International Sites Wikia messages
Entertainment
Gaming
Cartoons & Comics
Science Fiction
Hobbies
Sports
See all...
Grand Theft Auto
Terminator Wiki
Legend of Zelda Wiki
Flash Gordon
Everquest II Wiki
Yo-Yo Wiki
German
Spanish
Chinese
Japanese
More...
Wikia is hiring for several open positions
Send this article to a friend
"Source vimrc and use tags in a parent directory"
 
 
Hi!

I thought you'd like this page from Wikia!

http://vim.wikia.com

Come check it out!
Send confirmation