vimtricks.wiki Concise Vim tricks, one at a time.

How do I reload my vimrc or source a Vimscript file?

Answer

:source %

Explanation

The :source command reads and executes a Vimscript file. Using % as the argument sources the current file, making it easy to reload your vimrc.

How it works

  • :source ~/.vimrc re-reads your vimrc
  • :source % sources the current file (useful when editing vimrc)
  • All commands in the file are executed sequentially

Example

While editing your vimrc:

:source %    " Apply changes immediately

Or from anywhere:

:source ~/.vimrc    " Reload configuration

Tips

  • :so is the abbreviation for :source
  • Be careful with duplicate autocommands — use augroup with autocmd!
  • Some settings do not take effect until Vim restarts
  • :runtime is similar but searches the runtime path
  • Neovim uses ~/.config/nvim/init.vim or init.lua

Next

How do you yank a single word into a named register?