Is there an "include" procedure in vimrc?

55

9

I have some configuration in my vimrc. Some generic ones, and some other really specific.

I would like to share this config with some co workers, but a lot of them don't need these specific ones.

Instead of editing a bunch of different vimrc, I would like to know if it's possible to have an "include" directive - something like a file named ".vimrc_module" and called from vimrc. Is it possible?

Somebody still uses you MS-DOS

Posted 2010-06-15T12:46:06.007

Reputation: 4 143

Answers

74

Yes, it is possible, use the :source command:

source .vimrc_module

See:

:help :source

for more information.

Al.

Posted 2010-06-15T12:46:06.007

Reputation: 2 396

4

Plugins serve this purpose.

  • plain plugins are always loaded once,
  • autoload plugins are loaded on demand (they are ideal to define libraries of viml functions),
  • ftplugin are loaded once per buffer (when the ftplugin type matches the buffer type),
  • local vimrcs are loaded on a project-basis (non standard),
  • and so on.

In other words, we hardly need to use :source or :runtime explicitly from the .vimrc. Yes they exist. Do we really need them? Hardly! Vim already has several idioms that take care of that.

Luc Hermitte

Posted 2010-06-15T12:46:06.007

Reputation: 1 575