Skip to content

Instantly share code, notes, and snippets.

@nelstrom
Created June 30, 2011 11:32
Show Gist options
  • Star 69 You must be signed in to star a gist
  • Fork 6 You must be signed in to fork a gist
  • Save nelstrom/1056049 to your computer and use it in GitHub Desktop.
Save nelstrom/1056049 to your computer and use it in GitHub Desktop.
An overview of what belongs in each directory of a Vim plugin.
plugin
naming convention: name_of_plugin.vim
these files are sourced for all file types
doc
naming convention: name_of_plugin.txt
these files document the functionality of a plugin
color
naming convention: name_of_colorscheme.vim
these files define a colorscheme for syntax highlighting
syntax
naming convention: filetype.vim
these files define the operators, keywords and constructs of a language
the syntax groups defined here are used by the colorscheme
(much like HTML elements, ids and classes provide hooks for CSS styling)
indent
naming convention: filetype.vim
these files define the `indentexpr` for a language
the `indentexpr` is used by the `=`, `o` and `O` commands
ftplugin
naming convention: filetype.vim
these files are sourced only for the specified filetype
suitable for defining functionality for one particular language
e.g. a command to build an HTML document from a markdown source
autoload
naming convention: ???.vim
Vim provides a mechanism to ensure that startup time isn't compromised
when large scripts are loaded. Functions, commands and mappings defined
in the autoload directory are defined with an empty implementation on
startup. It is only when these commands are invoked by the user that the
script is sourced in full, and each command is attached to its
implementation.
:help autoload-functions
:help 41.14
@scottmessinger
Copy link

That's super helpful! Thanks!! I'd love to see this linked to on vimcasts!

@nelstrom
Copy link
Author

Glad it helped. You're right, it might be worth turning this into a blog post.

@simonrw
Copy link

simonrw commented Sep 12, 2013

It might be useful to add the "after" directory, and a note about how it contains a clone of this structure but is loaded after other scripts. In fact I'm not too sure about this myself, so an update here would be good.

@roxma
Copy link

roxma commented Aug 14, 2016

+1 for after directory.

@DreamAndDead
Copy link

DreamAndDead commented Apr 6, 2017

some personal opnions :)

  1. :help 41.15 to check autoload functionality
  2. dir color should be colors
  3. add dir ftdetect compiler

@erickvillegas
Copy link

Big thanks for this.

@mgarort
Copy link

mgarort commented Nov 24, 2020

+1 for after directory.

@avimehenwal
Copy link

just curious, does the same directory structure works with neovim?
I am thinking about totally ditching .vim/ direcectory and move everything to .config/nvim/.

@agarie
Copy link

agarie commented Jul 1, 2022

just curious, does the same directory structure works with neovim? I am thinking about totally ditching .vim/ direcectory and move everything to .config/nvim/.

Yeah, you can do that. Check :help vimfiles to see all about it. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment