Updated: 4 November 2026 · Applies to: Vim 9.1 and Neovim 0.11.6 (tested on Ubuntu 26.04)
To reload your Vim configuration without restarting Vim, type this in normal mode and press Enter:
:source $MYVIMRC
:so is the short form. $MYVIMRC holds the path of the vimrc Vim loaded at startup (for example /home/USER/.vimrc, or /root/.vimrc for root). If the vimrc is the file you are editing, save it and run :so % (% means the current file).
To reload the file you are editing (for example after another program changed it), use :e, or :e! to throw away your unsaved changes. Both are explained below.
Reload .vimrc step by step
- Edit your vimrc, for example
:e $MYVIMRC, and save it with:w. - Run
:source $MYVIMRC(or:so %while the vimrc is the open file). - Check that a setting took effect, for example
:set tabstop?. In our test, changingset tabstop=4toset tabstop=2and sourcing showedtabstop=2straight away.
Not sure which file Vim loaded? :echo $MYVIMRC shows it.
What sourcing does not do
:source runs the file again from top to bottom; it does not reset Vim first. Two side effects:
- Removed lines are not undone. We deleted
set nonumberfrom the vimrc and turned line numbers on by hand; after:source,numberwas still on. Undo such a setting yourself (:set nonumber) or restart Vim. - Autocommands pile up. A line like
autocmd BufWritePost *.txt echo "saved"is added again on every reload. After starting Vim and sourcing twice,:autocmd BufWritePostlisted the same command three times, so it ran three times on each save.
Prevent the second problem by putting your autocommands in a named group that clears itself first:
augroup MyVimrc autocmd! autocmd BufWritePost *.txt echo "saved" augroup END
With the group, the command was listed only once after the same reloads. Mappings and set lines are simply overwritten, so they do not need this.
Reload .vimrc automatically when you save it
Add one line to the group above:
augroup MyVimrc autocmd! autocmd BufWritePost *.txt echo "saved" autocmd BufWritePost $MYVIMRC source $MYVIMRC | echom "vimrc reloaded" augroup END
Now every :w on the vimrc reloads it. In our test, adding set shiftwidth=7 and saving printed vimrc reloaded, and :set shiftwidth? showed 7 without a manual :source.
Shortcut keys to edit and reload the vimrc
" Edit the vimrc nnoremap <Leader>ve :e $MYVIMRC<CR> " Reload the vimrc nnoremap <Leader>vr :source $MYVIMRC<CR>
The Leader key is a backslash unless you set g:mapleader (for example let mapleader = ","), so press \ve to open the file and \vr to reload it.
Reload the current file in Vim
:e(:edit) reads the file from disk again. It refuses if you have unsaved changes:E37: No write since last change (add ! to override):e!reloads and discards your unsaved changes. In our test the buffer went back to the saved text.- If another program changes the file while it is open, Vim's help says you get
W11: Warning: File "{filename}" has changed since editing startedand must decide which version to keep.:checktimemakes Vim check all open buffers now. - With
:set autoread, Vim reloads a changed file by itself when it checks, as long as you have no unsaved changes. In our test,:checktimewithautoreadloaded the new text without asking. Addset autoreadto your vimrc to keep it on.
Neovim
Neovim reads ~/.config/nvim/init.vim or ~/.config/nvim/init.lua, not ~/.vimrc, and $MYVIMRC points to that file. The same :source $MYVIMRC reloads it; it worked in Neovim 0.11.6 for both init.vim (set tabstop=2) and init.lua (vim.opt.tabstop = 6). autoread is already on by default in Neovim.
Check which editor you are running with vim --version | head -1. On Ubuntu 26.04 with both the vim and neovim packages installed, the vim command started Neovim (NVIM v0.11.6), so changes to ~/.vimrc seemed to do nothing. Choose the editor with sudo update-alternatives --config vim.
Related articles
- Enable syntax highlighting in Vi and Vim
- Delete all text in a file with Vi or Vim
- Compare files with diff, cmp and vimdiff
Official documentation: Vim help for :source, :edit and file reloading and autocommands.