Skip to content
Daniel Jones edited this page Aug 31, 2018 · 9 revisions

Important note: The ideas listed here are not officially supported. Please do not open issues about them. If you are not willing to take that risk please stick to the usage described in the documentation.

Vimrc for Windows & Linux

For those who want just one vimrc file for Windows and Linux the following snippet may be useful. Win shell is a variable that will only be true if you are on Windows and using the cmd.exe shell. In general, when on Windows and using posix like shells (i.e. Cygwin or msysgit) I prefer to stay posix like directory .vim. Otherwise, if I'm using GVim or vim from cmd.exe use vimfiles so as not to need to require hidden files.

let win_shell = (has('win32') || has('win64')) && &shellcmdflag =~ '/'
let vimDir = win_shell ? '$HOME/vimfiles' : '$HOME/.vim'
let &runtimepath .= ',' . expand(vimDir . '/bundle/Vundle.vim')
call vundle#rc(expand(vimDir . '/bundle'))

Startup Time Optimization

Installing a lot of plugins might slow down vim startup, and when it does, it is annoying. Locating which plugin effects the startup time significantly is the key to solve this issue. You can check out this project that automates the process of profiling the startup time, calculating the net sum of the time each plugin took during startup, then sorting them out (also generating a nice figure):

https://www.github.com/hyiltiz/vim-plugins-profile

Installing plugins in different and non standard places

The function vundle#rc can take one optional string argument to change the default prefix where all the plugins are installed (the default is ~/.vim/bundle). This way to change the location of your plugins is documented in the help file and the README. This method will affect the location of all plugins. There is also the name option which is manly designed to resolve name conflicts between plugins (see the relevant help section).

If you only want to have one or some plugins in a special location there are two other ways available. If your system supports it you can use symlinks. Just put any Plugin 'something' line in your vimrc and run VundleUpdate. The plugin will be installed to ~/.vim/bundle (if you did not change the default location). Now just move this new plugin folder somewhere else and symlink it back into ~/.vim/bundle. In a UNIX shell you can do it like this:

cd ~/.vim/bundle
mv something the/place/you/like
ln -s the/place/you/like/something .

If your system does not support symlinks (or if you do not want the extra symlink to be around) you can still force Vundle to put the plugin in any place you like. To do this you use the name option and provide it with a relative path from ~/.vim/bundle to the directory where you want the plugin to be. This means you can write this in your vimrc:

Plugin 'something', {'name': 'somwhere/subfolder/plug1'}
Plugin 'something-else', {'name': '../../somewhere/outside/plug2'}

Now Vundle will clone the plugin 'something' into ~/.vim/bundle/somewhere/subfolder/plug1 and the plugin 'something-else' into ~/somewhere/outside/plug2. These two directories will be added to your &runtimepath in Vim so the plugins will be loaded automatically.

Updating Vundle/Plugins from command line or automatically

In order to update Vundle.vim and all your plugins directly from the command line you can use a command like this:

vim -c VundleUpdate -c quitall

This command can also be put in a script or called via cron or however you want to get crazy. For automated updating it might be of use to also disable the viminfo:

vim -i NONE -c VundleUpdate -c quitall

And if you want you can even redirect the output and error messages to /dev/null (at least on Unix).

Customizing signs in the installer window

You can customize the signs used in the installer window of Vundle. To do so you have to put something like the following after the call to vundle#rc or vundle#begin in your vimrc file:

sign define Vu_error text=x texthl=Error

The signs which are defined by Vundle all start with "Vu_", you can see them all with the command :sign list. Also see :h :sign for more information.