Making Vim portable
Despite all the portable forks and complicated HOWTOs, making plain vim portable is pretty easy, actually I can't imagine it could get easier as you only need single line in config. At least on Windows, but I expect it to work elsewhere as well, let me know if I am wrong.
$VIM variable is relative to the executable and points to parent directory (
Z:\vim-portable in our case).
the unnecessarily long version
Let's mix in directory structure and pathogen.
Unpack the zips in
- vim74w32.zip (cmd version)
- gvim74.zip (GUI version)
- vim74rt.zip (runtime files)
_vimrcconfig file and insert:
" Make vim portable. let $HOME=$VIM " Load and run pathogen. runtime bundle/vim-pathogen/autoload/pathogen.vim execute pathogen#infect()
git clone pathogen into
vimfiles/bundledir. You could also just
autoloadpathogen, but I like it this way.
And the tree looks like this:
Z:\vim-portable | _vimrc | +---vim74 | | gvim.exe | | vim.exe | +---autoload | +---colors | +---compiler | +---doc | +---ftplugin | +---indent | +---keymap | +---lang | +---macros | +---plugin | +---print | +---spell | +---syntax | +---tools \---vimfiles \---bundle \---vim-pathogen
There are portable versions of vim that seem to be maintained, but personally I've never found a particular need for them: the standard Vim is portable enough for my needs.
Create a directory on your USB stick (let's assume that it's
E: when you're creating it):
Add two folders:
Copy the contents of
C:\Program Files\vim\vim73 (or wherever it's installed) into
E:\vim\vim73 and take your vim configuration files (if you have any) and put them in
E:\vim\vimfiles. Copy your vimrc to
Now put the USB stick in another PC (let's assume it mounts it as
F:). Open Windows Explorer, navigate to
F:\vim\vim73 and double click on gvim.exe. It will open the Vim GUI and load your configuration.
To keep the local and portable vim configurations matching, I'd recommend sticking the vimfiles directory under version control (also allows you to easily try out new plugins and then 'revert' to get rid of them if you don't want them) and having a checkout on the USB stick and another one on the PC. If you move your
vimfiles\vimrc and replace your
_vimrc with the following, it will keep vimrc version controlled with all the plugins and configuration:
" _vimrc - Links to the vimrc in the vimfiles directory runtime vimrc
You can do the same with
_gvimrc if you have one.