vim Extending Vim How plugins work


Example

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.

The principle

The '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

    • $HOME/.vim/
    • $VIM/vimfiles/
    • $VIMRUNTIME/
    • $VIM/vimfiles/after/
    • $HOME/.vim/after/
  • on Windows

    • $HOME/vimfiles/
    • $VIM/vimfiles/
    • $VIMRUNTIME/
    • $VIM/vimfiles/after/
    • $HOME/vimfiles/after/

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 $HOME/.vim/ or $HOME/vimfiles/.