views:

95

answers:

3

Let's say I have a tarball of all my vim config - everything normally inside ~/.vim (plugins, autoload, colours, all that stuff), and a vimrc file. I extract this to a directory somewhere. So in the directory where I am ($PWD), there is a "vim" folder and a "vimrc" file. (note: this directory will be read-only, so vim shouldn't try to write into it).

What command-line arguments or environment variables can I give to vim to ensure that all my plugins, syntax, etc is loaded as well as the vimrc, in the same order as they normally would if they were located in ~/.vim and ~/.vimrc

As a bonus, I'd like to ignore the host computer's ~/.vimrc and ~/.vim if possible (but this is not mandatory).

If you're wondering why I don't just chuck the files in ~/.vimrc and ~/,vim, I'm trying to package up my own vim configuration and take it with me. I don't want to clobber the vim config of the computer I'm using, I just want to start a vim session with my config.

A: 

On Unix & Linux systems (and maybe Windows) Vim uses the $HOME environment variable to locate the .vimrc file and .vim directory. So you can cd into the directory where you have your custom versions and start vim or gvim like this:

HOME=. vim files....
Dave Kirby
good idea, but there are a couple of problems:(1) this breaks opening up files using ~ (like :e ~/Docs/whatever.txt).(2) I forgot to mention this, but the working directory has to be readonly (I'll update the question). vim complains when it can't write to ~/.viminfo, etc
gfxmonk
A: 

This "vimrc File and Vim Runtime Directories" screencast might be useful, as well as the vim documentation for 'runtimepath', which states the following:

This is a list of directories which will be searched for runtime files:
      filetype.vim  filetypes by file name |new-filetype|
      scripts.vim   filetypes by file contents |new-filetype-scripts|
      autoload/ automatically loaded scripts |autoload-functions|
      colors/   color scheme files |:colorscheme|
      compiler/ compiler files |:compiler|
      doc/      documentation |write-local-help|
      ftplugin/ filetype plugins |write-filetype-plugin|
      indent/   indent scripts |indent-expression|
      keymap/   key mapping files |mbyte-keymap|
      lang/     menu translations |:menutrans|
      menu.vim  GUI menus |menu.vim|
      plugin/   plugin scripts |write-plugin|
      print/    files for printing |postscript-print-encoding|
      spell/    spell checking files |spell|
      syntax/   syntax files |mysyntaxfile|
      tutor/    files for vimtutor |tutor|

    And any other file searched for with the |:runtime| command.

    The defaults for most systems are setup to search five locations:
    1. In your home directory, for your personal preferences.
    2. In a system-wide Vim directory, for preferences from the system
       administrator.
    3. In $VIMRUNTIME, for files distributed with Vim.

                            *after-directory*
    4. In the "after" directory in the system-wide Vim directory.  This is
       for the system administrator to overrule or add to the distributed
       defaults (rarely needed)
    5. In the "after" directory in your home directory.  This is for
       personal preferences to overrule or add to the distributed defaults
       or system-wide settings (rarely needed).
David Rivers
thanks. I actually had tried setting runtimepath, but it didn't seem to work for loading pathogen functions (it lives in autoload, which I thought was causing trouble). It turns out it was just bailing out for other reasons (cp mode was on). My final script sets $VIM_BASE, and my skelton vimrc adds $VIM_BASE to runtimepath and then sources the *real* vimrc.
gfxmonk
Have never used pathogen. Sorry, there's not much else I can add!
David Rivers
+2  A: 
too much php