A plugin is a script or set of scripts that changes Vim's default behavior, either by adding non-existing features or by extending existing features.
Often added "non-existing features" include:
- indentation detection,
- support for a specific language,
Often extended "existing features" include:
- text-objects & motions,
- yanking & putting,
- status line,
- search & replace,
- buffer/window/tab page switching,
How plugins work
A plugin could present itself as a single file containing 30 lines of vimscript or as 20MB of vimscript/python/ruby/whatever split into many files across a dozen of directories that depends on a number of external tools.
The former is obviously easy to install and manage but the latter could pause quite a challenge.
'runtimepath' option tells Vim where to look for runtime scripts. The default value makes Vim look for scripts into the following directories in order:
on UNIX-like systems
Of the directories above, only install plugins into the ones in bold. The others will cause instability for no good reason. Installing a plugin boils down to placing each of its components in the right directory under
vim-pathogen is a
runtimepath manager created by Tim Pope to make it easy to install plugins and runtime files in their own private directories.
Put pathogen in
~/.vim/bundle(here with Git, but it's not mandatory):
Add the following lines to the top of your
runtimedirective specifies the path to the autoload script of
execute pathogen#infect()initiates it.
Once initiated, Pathogen will automatically start a sweep through the folders in
~/.vim/bundle and load the plugin from each of them.
- Put the top-level directory of your plugin in
~/.vim/bundle/to make it available next time you start Vim.
:Helptagsto index your new plugin's documentation.
- Each plugin resides in its own directory under
.vimrcstays clean from the configuration needed to load plugins.
The effort needed to "manage" a plugin is thus reduced to:
- put its top-level directory under
~/.vim/bundle/to install it,
- replace its top-level directory to update it,
- delete its top-level directory to uninstall it.
How you perform those three actions (manually, via an automation tool, with Git/Svn/Hg/whatever…) is completely up to you.
The future: packages
The manual method
Single file plugin
Put the file under
This would source the plugin on startup of Vim. Now the user could use everything defined in it.
If the plugin however needs activation, the user either has to execute the command themselves whenever they want to use it, or add the command to
A bundle is a directory structure that the plugin uses. It consists of all the files of the plugin under the appropriate sub-directories.
To install such a plugin the sub-directories should be merged with their counterparts in
$HOME/.vim/plugin. This approach however leads to mixing of the files of different plugins in the same directories and could possibly lead to namespace problems.
Another approach is to copy the entire directory into
When using this approach there should be at least one
.vim file under the
$HOME/.vim/bundle/autoload directory. These files would be sourced by vim on startup.
Note: Depending on the operating system of the user the prefix of all paths might be
$HOME/vimfiles. For more details see How plugins work
Vundle is a plugin manager for Vim.
(Full installation details can be found in the Vundle Quick Start)
Install Git and clone Vundle into
Configure plugins by adding the following to the top of your
.vimrc, adding or removing plugins as necessary (the plugins in the list are merely for illustration purposes)
Install Plugins: by launching Vim and running
Supported Plugin Formats
The following are examples of different formats supported. Keep Plugin commands between
|plugin on GitHub|
|plugin from http://vim-scripts.org/vim/scripts.html|
|Git plugin not hosted on GitHub|
|git repos on your local machine (i.e. when working on your own plugin)|
|The sparkup vim script is in a subdirectory of this repo called vim. Pass the path to set the runtimepath properly.|
|Install L9 and avoid a Naming conflict if you've already installed a different version somewhere else.|
Working on a shared account, for example, on cluster head node can raise issues from the point of disk usage by
.vim directory. There are a couple of packages which take considerable amount of disk space, for example YCM. So please choose your
Vundle plugin directory wisely, and its very easy to do so by setting
rtp. And also if you are planning to install any vim plugin, don't directly do
git clone in the
bundle directory. Use the Vundle way.