Vim Recipes ‣ Extending ‣ Extending Vim with Scripts and Plugins
You want to add functionality to Vim, preferably without having to write it yourself.
Browse Vim Scripts to find a script that meets your needs. Its 'type' should be utility or ftplugin. Download the latest version to your computer. If the plugin comes with its own installation instructions, use those; otherwise, read on.
If the file you've downloaded has a name ending with .vim you usually just need to save it in the right directory and then its ready to use. For scripts labelled utility, also known as global plugins, this directory is $VIMHOME/plugin; for those labeled ftplugin, also known as filetype plugins, the last component of this path is ftplugin instead. If this directory does not already exist you need to create it. The sidebar lists the locations of the plugin directories on various operating systems.
If the file is compressed (ending with .zip or .tar.gz), try uncompressing it in the parent directory of the applicable plugin directory. For example, on Linux this is ~/.vim/.
Now you should just be able to start Vim and have the plugin work.
Plugin Directory Location
Note: For filetype plugins, the last portion of these paths is ftplugin; not plugin.
- Unix
- ~/.vim/plugin
- PC and OS/2
- $HOME/vimfiles/plugin or $VIM/vimfiles/plugin
- Amiga
- s:vimfiles/plugin
- Macintosh
- $VIM:vimfiles:plugin
- Mac OS X
- ~/.vim/plugin
- RISC-OS
- Choices:vimfiles.plugin
Plugins can be either global or filetype-specific. Global plugins are loaded for every file you open; filetype-specific plugins are only loaded for certain filetypes.
As complicated as the above instructions may sound, it's generally trivial to install a plugin. For example, on Linux to install the potwiki plugin:
$ mkdir -p ~/.vim/plugin $ wget http://www.vim.org/scripts/download_script.php?src_id=9316 -O ~/.vim/plugin/potwiki.vim
(If your plugin directory already exists, the first command is superfluous.)
Vim 7 added support for a new plugin installation method called vimball. Vimballs make plugin installation and configuration easier, and are a slight improvement over the previous methods. They're not in wide use yet, but if you find a plugin distributed in this way (they have a *.vba extension), try following the steps below: