About plugin a good introduction is Learn Vimscript the Hard Way.
In particular the chapter 42: Plugin Layout in the Dark Ages will give you the role of the different folders and files.
Here is my understanding:
The first script to be loaded is .vimrc
if it exists:
.vimrc
When Vim starts it executes the following scripts (from: vimfiles
, your installed plugins, Vim distribution plugins):
plugin/*.vim
ftdetect/*.vim
Then in executes the following scripts (from: vimfiles
, your installed plugins, Vim distribution plugins):
after/plugin/*.vim
When Vim loads a file of type: mytype it executes the following scripts (from: vimfiles
, your installed plugins, Vim distribution plugins):
ftplugin/mytype.vim
after/ftplugin/mytype.vim
indent/mytype.vim
after/indent/mytype.vim
syntax/mytype.vim
after/syntax/mytype.vim
When Vim calls a function myscript#myfunction it executes the following scripts searching for the myscript#myfunction
(from: vimfiles
, your installed plugins, Vim distribution plugins):
autoload/myscript.vim
There are two other folders with special meaning.
The script colors/mycolor.vim
is executed when the command :colorscheme mycolor
is executed.
When the command :compiler mycompiler
is executed Vim executes the following scripts (from: Vim standard, your installed plugins, Vim distribution plugins):
compiler/mycompiler.vim
after/compiler/mycompiler.vim
Remark: You can learn more about in which order the scripts are executed using the :scriptname
command.