I understand that it loads the ftplugin.vim file, but what does it really do? Does it set options (depending on the filetype)?

If I were to include this line at the start of my vimrc

filetype plugin indent on

and then I set some options after this line (like autoindent, smartindent, etc.), would it mess with them? How can I know which options are affected by a filetype plugin or indent file?

2 Answers 2


There is actually a good description in help filetype.

Any options that are defined for a filetype will be set with setlocal:

:setl[ocal] ...     Like ":set" but set only the value local to the
                    current buffer or window.  Not all options have [..]

For example /usr/share/vim/vim80/ftplugin/javascript.vim defines:

setlocal commentstring=//%s

Because local options have priority over global ones your .vimrc settings might be ignored. In that case you need to create a file ~/.vim/after/ftplugin/javascript.vim (with the name of the filetype you wish to change) and set your own setlocal options in there.

The easiest way to see which options are set is to just open the files for the filetype in /usr/share/vim/vim80/ftplugin, ../indent and ../syntax.


It defines autocommands that'll get executed when a file matching a given pattern is opened. These autocommands source in turn the filetype plugins associated to the filetype recognized.

In those filetype plugin scripts, you'll be able to find/write anything that you can put in a vim script. The good practice is no never define global things, but exclusively local things. i.e:

  • local options with :setlocal opt=value
  • local mappings with :[cnivsxot](nore)map <buffer> ...
  • local abbreviations with :iab-<buffer> ... & co
  • local commands with :command -b ...
  • local variables with :let b:var = 42


  • menus, you'll have to use plugins that emulate local menus, see Michael Geddes' plugin or my modernized fork ;
  • functions, you can put them in ftplugins, but they are best defined in autoload plugins.
  • So there are three kinds of built-in plugin systems: ftplugin/, indent/, and autoload/? Commented Mar 9, 2023 at 16:50
  • 1
    @job_start there are more: compiler/ plugins, syntax/ files, plain plugin/ files, and a few more like colorscheme/. If you :sp $VIMRUNTIME you should see how vim organizes standard "plugin" files. Commented Mar 9, 2023 at 22:03
  • I just played around(opening) some of them and this is really helpful, thank you :)! By the way, while not related but: could you explain why it's called "runtime"? Commented Mar 10, 2023 at 2:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.