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 ~/.vimrcre-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
:sois the abbreviation for:source- Be careful with duplicate autocommands — use
augroupwithautocmd! - Some settings do not take effect until Vim restarts
:runtimeis similar but searches the runtime path- Neovim uses
~/.config/nvim/init.vimorinit.lua