Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Please explain Vim's configuration directories hierarchy

Tags:

vim

vim-plugin

I am trying to update my Vim configuration scripts. There are a number of sub-directories in my ~/.vim directory and I'm not sure the specifics of what they do, nor why there are some that seem to be redundant.

Here is what my ~/.vim directory tree looks like

 |-after
 |---ftplugin
 |---syntax
 |-autoload
 |-compiler
 |-doc
 |-ftplugin
 |---latex-suite
 |-----dictionaries
 |-----macros
 |-----packages
 |-----templates
 |---python
 |-indent
 |-plugin
 |-spell
 |-syntax

Now for the specific questions.

  1. What goes in plugin vs ftplugin?
  2. What is the difference between plugin and autoload?
  3. When should I put something in after/... instead of in the directories directly under ~/.vim?
like image 384
jlconlin Avatar asked Jan 09 '13 23:01

jlconlin


3 Answers

Whatever goes into plugin is loaded whenever vim starts whereas what you put in ftplugin is only loaded for the specific filetype it corresponds to (so if you have a folder there called python all the files there will be loaded when you open a python file. In autoload you should have the functions corresponding to the the scripts defined in plugin. The functions here will only be loaded when called by the first time.

In after you should put settings that you want to change from the normal plugin loading. As an example suppose you like the settings that some plugin for latex gives you, but it redefined a mapping that you had in your .vimrc. You can revert this with autocommands or by putting the correct definitions in after.

like image 67
skeept Avatar answered Oct 21 '22 02:10

skeept


I think this would explain exactly what each folder does: http://learnvimscriptthehardway.stevelosh.com/chapters/42.html

Also might want to check :h runtimepath.

Hope this helps. :)

like image 13
greduan Avatar answered Oct 21 '22 04:10

greduan


All those directories are part of the runtimepath. Try :h runtimepath and it will link you to your answers:

  1. Check :h write-plugin
  2. Check :h autoload-functions
  3. after/... scripts are executed last, so they can override settings of earlier scripts. You can read more about this in :h runtimepath.
like image 10
Daan Bakker Avatar answered Oct 21 '22 02:10

Daan Bakker