I understand that we can extend the power of Vim in order to add new features or modify existing ones and enhance our editing experience.

Although being myself a Vim user for quite a long time, I am now in an uncharted territory: what is exactly a Vim plugin? What are the prerequisites for writing a plugin, so I can write my own plugins in the near future?

1 Answer 1


A plugin is a way to extend vim's functionality.

Vim categorizes plugins into "global" plugins (which load and operate unconditionally) and "filetype" plugins (which only load and operate for specific file types, see :help filetype). Vim looks for plugins in specific locations, assuming you have not altered the runtime path (manually or with plugins like Pathogen or Vundle):

  • On *nix and OS X, the default is ~/.vim/plugin
  • On Windows, the default is $HOME/vimfiles/plugin

Filetype plugins use ftplugin instead, and must be named (or in a subdirectory named) for the filetype they correspond to (such as foo.vim for the foo filetype).

Plugins are just vim script, so you can use them to define functions, mappings and commands just like you might in your .vimrc, although when writing a plugin you generally want to write your vim script with a little more generality than you might if you were just hacking on your own .vimrc. If your vim is compiled with the appropriate option, you can also write plugins in other languages such as Python, Ruby or Lua.

Plugins are usually more than just a single .vim file that sits in the appropriate directory, however. They frequently also include autoload scripts (:help autoload), syntax scripts (:help syntax) and indent handling scripts. Packaged together all of the code in these scripts provide for powerful hooks to augment vim.

Vim's built-in help (:help plugin) contains all sorts of additional specifics. Writing plugins is a pretty broad topic, but vim's built-in help can be extremely useful. Additionally, there are some excellent resources on the internet such as:

Using a plugin (whether one you've written or one you've download from the internet) is a simple matter of placing it in the appropriate directory (or directories, if applicable) and launching vim. Some plugins may have more complex installation procedures (such as the popular YouCompleteMe completion plugin, which has a compiled component), of course.

These days, plugin-management plugins such as Pathogen and Vundle are a popular alternative to manually installing plugin files, especially since plugins usually come with more than one file (as noted above). See this question for more information.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.