How do I quickly open my vimrc configuration file from anywhere in Vim?
Answer
:e $MYVIMRC
Explanation
The :e $MYVIMRC command opens your Vim or Neovim configuration file instantly, no matter where it lives. The $MYVIMRC variable is set by Vim at startup and always points to the correct config file — whether that's ~/.vimrc, ~/.config/nvim/init.vim, or ~/.config/nvim/init.lua.
How it works
$MYVIMRCis a built-in Vim environment variable automatically set to the path of the loaded vimrc:e(:edit) opens the file in the current window- Since
$MYVIMRCis expanded by Vim before the shell, it works correctly even if the path contains spaces or platform-specific separators - You can inspect its value with
:echo $MYVIMRC
Example
:echo $MYVIMRC
" → /home/user/.config/nvim/init.lua
:e $MYVIMRC
" → opens the file
After editing, reload the config without restarting:
:source $MYVIMRC
Tips
- Map this to a leader key for instant access from any buffer:
nnoremap <leader>ev :e $MYVIMRC<CR> - Pair with a reload mapping:
nnoremap <leader>sv :source $MYVIMRC<CR> - Use
:tabe $MYVIMRCto open in a new tab without losing your current layout - For Neovim Lua users,
$MYVIMRCstill works even when usinginit.lua