Let’s build a plugin
Let’s try building a simple plugin; this way, we can learn by example.
A common task you have to perform when working with code is commenting out chunks of code. Let’s build a plugin that does just that. Let’s (uninspiringly) name our plugin vim-commenter
.
Plugin layout
Since the Vim 8 release, there’s thankfully only one way of structuring your plugins (which is also compatible with major plugin managers, such as vim-plug, Vundle, or Pathogen). The plugins are expected to have the following directory structure:
autoload/
lets you lazy load bits of your plugin (more on that later)colors/
color schemescompiler/
(language-specific) compiler-related functionalitydoc/
documentationftdetect/
(file type-specific) file type detection settingsftplugin/
(file type-specific) file type-related plugin codeindent/
(file type-specific) indentation-related settingsplugin/
the core functionality...