Easily add/remove Vim scripts 7

Posted by ryan Tue, 20 Jul 2010 01:39:00 GMT

I like being able to easily add and remove Vim scripts, whether it's to try one out or easily upgrade to a newer version down the line. Since the directory structure of a script almost always follows the standard runtime directory structure, I simply wrote a script that adds each directory under $HOME/.vim/vendor to Vim's runtimepath, so that Vim includes the vendor directories in its script-searching behavior. That way, I can simply download something like rails.vim, which has files in autoload, doc, and plugin, and would be very annoying to remove manually, uncompress it into its own directory under $HOME/.vim/vendor, restart Vim, and the script is loaded. Removing the script is as easy as removing the directory under vendor and restarting Vim.

To add this behavior, simply put the following in your $HOME/.vimrc file:

let vendorpaths = globpath("$HOME/.vim", "vendor/*")

let vendorruntimepaths = substitute(vendorpaths, "\n", ",", "g")
set runtimepath^=vendorruntimepaths

let vendorpathslist = split(vendorpaths, "\n")
for vendorpath in vendorpathslist
  if isdirectory(vendorpath."/doc")
    execute "helptags ".vendorpath."/doc"
  endif
endfor

For the latest and greatest version of this code, refer to my vimrc.

Comments

Leave a comment

  1. Exchange 2 months later:

    Very well written. You got every point explained. Loved the whole article! Many thanks!

  2. Currency 3 months later:

    This way of add and remove Vim scripts is pretty cool and will save a lot of my time.Thanks : )

  3. darmowe krzyzowki 9 months later:

    Great blog post, I have been waiting for that

  4. darmowe pozycjonowanie 9 months later:

    This is the greatest topic I have read today

  5. linux 9 months later:

    Thanks for this great post. Did you do it all on your own? This must've taken a lot of time

  6. susan about 1 year later:

    Very Cheap Pro Cycling Online Shop www.bike-jersey.net for Cycling Jerseys.They have great quality and very cheap price ,also could offer the great service and fast shipping!!!

  7. online pokies over 2 years later:

    it should be very interesting book. I would read it.

Comments