Home  >  Q&A  >  body text

How to set and modify _vimrc in vim to take effect without restarting vim?

It’s very troublesome to have to restart after every change

大家讲道理大家讲道理2712 days ago800

reply all(5)I'll reply

  • 迷茫

    迷茫2017-05-16 16:44:23

    :so $MYVIMRC

    reply
    0
  • 黄舟

    黄舟2017-05-16 16:44:23

    Since you are talking about _vimrc, it should be under Windows.

    If your _vimrc is placed in %ProgramFiles%/vim/_vimrc, you can use it like this

    :source $VIM/_vimrc

    If it is in %USERPROFILE%/_vimrc, then you can use it

    :source $HOME/_vimrc

    or

    :source ~/_vimrc

    In addition, the latter is used under Linux/Unix, but the file name is generally .vimrc.

    reply
    0
  • 仅有的幸福

    仅有的幸福2017-05-16 16:44:23

    Add the following content to .vimrc or _vimrc:

    " autoload _vimrc
    autocmd! bufwritepost $HOME/.vimrc source %

    It’s feasible, mainly $HOME/.vimrchere, change it as needed, please refer to the Vim Chinese user manual for details

    reply
    0
  • 过去多啦不再A梦

    过去多啦不再A梦2017-05-16 16:44:23

        "$MYVIMRC 是你的vimrc路径
        autocmd! bufwritepost vimrc source $MYVIMRC

    Of course, the premise is to have autocmd detection method

        命令行模式 echo has('autocmd') 
        " 返回1 表示有 返回0 表示没有

    So it can be like this

    if has("autocmd")
        autocmd! bufwritepost vimrc source $MYVIMRC
    endif

    reply
    0
  • 怪我咯

    怪我咯2017-05-16 16:44:23

    : source + configuration file, I remember there is a plug-in that can detect changes in your local configuration file and automatically read it in. You can google it. However, I personally feel that this function does not make much sense, after all, the configuration file is not changed frequently.

    reply
    0
  • Cancelreply