Vim
Contents
vimrc
Initial configuration happens in the vimrc file, located at ~/.vimrc or ~/.vim/vimrc.
GVim looks in ~/_vimrc or ~/vimfiles/vimrc.
Runtime Path
Configurations are loaded using the runtimepath variable. Each entry is a directory that will be searched for configuration files. A standard file structure (see below) is assumed.
The loading order goes...
local configuration is loaded from ~/.vim (or ~/viminfo for GVim).
system configuration is loaded from $VIMRUNTIME.
after local configuration is laoded from ~/.vim/after (or ~/vimfiles/after for GVim).
To load an additional configuration directory, append the path to runtimepath. This should be done by editing the vimrc file.
execute 'set runtimepath+=' . expand('path/to/organization/configuration')
Directory Structure
Plugins and configurations are loaded based on a standard directory structure.
After
The after directory is meant for files that should override previously evaluated files, which is achieved by loading after all others.
Autoload
Libraries should be placed in the autoload directory.
Note that functions are loaded into memory but not evaluated. Given a function foo located in autoload/mylib, it can be called like:
call mylib#foo()
Plugin
Plugins that are always loaded should be located in the plugin directory.
File Type Detection
Many subsequent processes branch based on the filetype variable. This is set through one of the following:
the filetype.vim file is executed, setting generic system configuration
the ftdetect directory is searched for a file matching the current buffer's file extension. (i.e. with foo.bar opened for editing, ftdetect/bar.vim would be loaded.)
the scripts.vim file is executed, setting generic local configuration
Note that this is all skipped if the filetype variable is set to off`.
Ftdetect
ftdetect plugins should look like:
autocmd BufNewFile,BufRead *.bar setfiletype foobar
Syntax
Based on filetype, a syntax highlighting plugin may be loaded. With foo.bar opened for editing and filetype set to bar, configuration will be loaded from syntax/bar.vim.
Note that this is skipped if the filetype variable is set to off ''or'' if the command :syntax off` was run.
Ftplugin
The ftplugin.vim file is executed. Typically this is used for generic system configuration.
Based on filetype, a language plugin may be loaded. With foo.bar opened for editing and filetype set to bar, configuration will be loaded from ftplugin/bar.vim.
Note that this is skipped if the filetype variable is set to off`.
Indent
The indent.vim file is executed. Typically this is used for generic system configuration.
Based on filetype, an indentation plugin may be loaded. With foo.bar opened for editing and filetype set to bar, configuration will be loaded from indent/bar.vim.
Note that this is skipped if the filetype variable is set to off`.
Compiler
Based on filetype, a compiler plugin may be loaded. With foo.bar opened for editing and filetype set to bar, configuration will be loaded from compiler/bar.vim.
Note that this is skipped if the filetype variable is set to off`.
Colors
Color scheme plugins should be placed in the colors directory.
When the :colorscheme NAME command is executed, colors/NAME.vim is executed.
Pathogen
One of the most popular package management solutions for Vim is Pathogen. Pathogen is a short plugin that recursively searches an additional bundle directory. Discovered sub-directories are added to the runtimepath option between local and system configuration.
Neovim
Neovim follows the XDG standard, and checks for configuration in ${XDG_CONFIG_HOME}/nvim. The standard is also to use ${XDG_CONFIG_HOME}/init.vim instead of a vimrc file.