0

Every now and then I update my ViM configuration, and I would like to have a way to reload everything.

I know that I could use

:source ~/.vimrc

and I could run it similarly for all the modified files. But as vim loads e.g. the system-wide configuration and the content of the ~/.vim/ directory, it can be some effort to source all those files again.

Is there a way to reload the whole set in one command?

Ideally, it should stop sourcing the previous configuration file and resource all anew.

1
  • Vimdoc 3.c says: Four places are searched for initializations. The first that exists is used, the others are ignored. "$HOME/.vimrc" is searched first. And then 4::runtime! plugin/**/*.vim The result is that all directories in the 'runtimepath' option will be searched for the "plugin" sub-directory and all files ending in ".vim" will be sourced (in alphabetical order per directory), also in subdirectories. But if you using one of plugin-manager it reload your plugins with source command I believe.
    – Alex Kroll
    Commented Sep 3, 2019 at 8:22

2 Answers 2

2

3 options

  1. Restart vim (using sessions, e.g., with tpope’s obsession plugin, this isn’t really too bad)
  2. Source only your vimrc (if it changed)—you have this
  3. Load files with runtime (I use Runtime from tpope’s scriptease plugin).
0

Are your "modified files" not sourced by default of from within .vimrc?

If you add the

source /path/to/additional/config/file

directive to your .vimrc, that would do the whole thing in one go.

You can then even

nnoremap <leader>r :source ~/.vimrc<CR>

to have <leader>r (default <leader> is /, I believe) reload your config with two keystrokes.

Two things additionally:

  1. Thank you for asking the question! This prompted me to - at last - also put this into my own config. Very convenient!
  2. I set <leader> to be the Space key (let mapleader = " ") and am very happy with that.

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.