Is it possible to apply vim configurations without restarting?

后端 未结 5 1171
南笙
南笙 2020-12-12 19:45

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

5条回答
  •  南方客
    南方客 (楼主)
    2020-12-12 20:07

    Here's a more cross-platform compatible version if you run on 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 autocmd watches all potential *vimrc files and when one changes, it reloads the vimrc file followed by gvimrc if the GUI is running.

提交回复
热议问题