Is it possible to use vim configurations without restarting?

I want to edit the .vimrc file from Vim and apply them without restarting Vim.

+45
vim
Mar 08 '10 at 9:16
source share
5 answers

Yes, just use the command :so % while editing .vimrc.

If you want vim to automatically reload your configuration, you must add the following commands:

 augroup myvimrchooks au! autocmd bufwritepost .vimrc source ~/.vimrc augroup END 

auto-command grouping is here to avoid an "exponential" reboot if you save your configuration several times.

+46
Mar 08
source share

This is a more cross-platform compatible version if you are running Mac / Windows / Linux and gvimrc :

 augroup myvimrc au! au BufWritePost .vimrc,_vimrc,vimrc,.gvimrc,_gvimrc,gvimrc so $MYVIMRC | if has('gui_running') | so $MYGVIMRC | endif augroup END 

The machine keeps track of all potential *vimrc files, and when it changes, it reloads the vimrc file, followed by gvimrc if the GUI works.

+37
Mar 08 '10 at 19:05
source share

enter your vimrc file :source ~/.vimrc

+18
Mar 08
source share
 " Quickly edit/reload this configuration file nnoremap gev :e $MYVIMRC<CR> nnoremap gsv :so $MYVIMRC<CR> 

To automatically reboot on save, add the following to your $MYVIMRC :

 if has ('autocmd') " Remain compatible with earlier versions augroup vimrc " Source vim configuration upon save autocmd! BufWritePost $MYVIMRC source % | echom "Reloaded " . $MYVIMRC | redraw autocmd! BufWritePost $MYGVIMRC if has('gui_running') | so % | echom "Reloaded " . $MYGVIMRC | endif | redraw augroup END endif " has autocmd 

and then for the last time type:

 :so % 

The next time you save vimrc , it will automatically restart.

Features:

  • Tells the user what happened (also logged in :messages )
  • Handles various names for configuration files
  • Ensures compliance only with the actual configuration file (ignores copies in other directories or fugitive:// diff)
  • Will not generate an error when using vim-tiny

Of course, an automatic reboot will only happen if you change your vimrc to vim.

+3
Sep 02 '16 at 14:12
source share

autocmd! bufwritepost source _vimrc%

this will automatically reload the entire configuration in the _vimrc file when saving

+1
Mar 18 '10 at 15:30
source share



All Articles