As per the title, is it possible to split the vimrc file in several sub-files? Keep separate files for groups of settings that concern one thing? This thing might be anything, any kind of user-defined group of settings. For example,


  • keep all Python(-mode) related settings in vimrc.python-mode?
  • keep settings for the Calendar utility for vim in vimrc.calendar?
  • keep color setting in a separate file?
  • keep mappings (aka shortcuts?) in a separate file?
  • 3
    The flip side: location-based grouping instead of filetype-based. See vi.stackexchange.com/q/77/205 – muru Nov 11 '15 at 9:26
  • Might the answer I am looking for be somethere among the lines in vi.stackexchange.com/a/3152/1963? Source files which contain the settings I want for specific things I need? – Nikos Alexandris Nov 11 '15 at 9:47
  • Removed the filetype tag -- for now maybe? It makes readers think the questions is about specific file types, which is not the case. – Nikos Alexandris Nov 12 '15 at 10:27
  • it seemed appropriate given the original question. – muru Nov 12 '15 at 10:42
  • @muru Yes, no worries. We might add that later on as well. Thank you. – Nikos Alexandris Nov 12 '15 at 10:53

Yes this is possible and useful and even considered best practice. They are called filetype plugins in Vim speech. And Vim even comes with many filetype plugins (as well as indent and syntax files) for several languages.

You need to enable this in your .vimrc like this:

filetype plugin on

then put your specific filetype settings into a file (creating non-existing directories) called ~/.vim/ftplugin/python.vim for python settings. This is also covered in the FAQ.

Update (13.11.2015) There is also another possibility (if you don't want to use filetype specific options): If you want to group some options to a specific file, you can make use of the source or runtime command. For example my .vimrc contains this line:

" This script contains plugin specific settings
source ~/.vim/plugins.vim
" This script contains mappings
source ~/.vim/mapping.vim
" additional helper functions:
source ~/.vim/functions.vim
" For abbreviations read in the following file:
source ~/.vim/abbrev.vim
  • Nice, I already have this! But never really had a close look. So, I pumped up vimrc. What about settings that do not concern a specific filetype though? – Nikos Alexandris Nov 11 '15 at 9:37
  • 2
    You may need :he autoload and :he source? Also check this answer stackoverflow.com/a/805242/1821490 – Alex Kroll Nov 11 '15 at 22:33
  • @AlexKroll not for filetype plugins. – Christian Brabandt Nov 12 '15 at 7:01
  • @ChristianBrabandt for everything you want. You can source any script in .vimrc. Just put source my-funy-useful-script.vim line in your .vimrc and Vim loads it after restarting( or :so $MYVIMRC command). Also :he writing-library-scripts may helps you. – Alex Kroll Nov 12 '15 at 7:20
  • @AlexKroll I think this is closer to the answer I am looking for. Would you mind editing the current answer and expand it? Or, make a separate answer? I am not looking only for specific file types. I hope this is clear in my question. – Nikos Alexandris Nov 12 '15 at 10:19

It is completely possible to do what you want. Some of the others have said about filetype plugins which work well for that.

But you can source and .vim file in your vimrc so you can split the .vimrc into as many files as you would like. Just source the file and it will work. As a example here is my (probably not very useful) dotfiles. https://github.com/dspecht/dotfiles/

  • Could you please give an example of what you did in your answer and why it works? – EvergreenTree Nov 14 '15 at 23:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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