I'm quite new to Vim, and, since I'm writing my very own .vimrc file, I was wondering if there is a way to store all the commands relative to a certain plugin configuration in one external file, in order to make the original .vimrc file less dense, and how can I call that file in my .vimrc file. Any help will be appreciated.

EDIT: I forgot to say that I'm currently using Pathogen as plugin manager.


You can separate settings for plugins in several files, and include them in .vimrc

For example:

" My Plugin settings {
if filereadable(expand('~/.vim/my.plugin.settings.vim'))
  source ~/.vim/my.plugin.settings.vim
" }
  • Thank you! Where I have to put the if block? At the beginning of the file? – g_rmz Feb 11 '17 at 12:40
  • I figured out where to put that block, thank you again! – g_rmz Feb 11 '17 at 15:31
  • You can put it instead of the block with plugin settings. You're welcome! – Iryston Feb 11 '17 at 18:59

If Pathogen is not registering plugins before $HOME/.vim (which is extremely unlikely), you could simply drop your configuration file into $HOME/.vim/plugin/. That's all. No need to test anything (*), nor to be explicit. IOW: no need to write anything in your .vimrc to configure your plugins if you use a plugin manager.

(*) Actually, there is really no need to test anything: :runtime my.plugin.settings.vim wouldn't have barked at you if the file wasn't there, and it would have sourced if it were.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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