Sourcing vimrc without leaving vim

When you edit your .vimrc file you need to restart Vim or better source it to take action of the changes with:

:source $MYVIMRC 

or shorter


With some mapping we can make both editing and sourcing without leaving Vim by adding these 2 lines to .vimrc

nnoremap <silent> <leader>ve :vsplit $MYVIMRC<CR>
nnoremap <silent> <leader>vs :w <bar> source $MYVIMRC<CR>

My leader key is “-”, you can set your own by setting mapleader variable.

let mapleader = "-"

Now when I want to edit .vimrc I type “-ve” to edit it and after save and exit I run “-vs” 😄

Update: Just saw this on here and it seems to work 😄😄.

autocmd! bufwritepost .vimrc source %


117 Words

2018-08-30 03:00 +0300