Progressively slower reloading time of .vimrc

后端 未结 2 1951
半阙折子戏
半阙折子戏 2021-02-18 23:07

My boot time for vim is about a half second (tested with \"--startuptime\"), but after I reload vimrc a couple times via source, it gets slower subsequently. I have

2条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-02-19 00:00

    This is my solution that also clears previous mappings:

    augroup VimrcGroup
      autocmd!
      " Make changes effective after saving .vimrc. Beware that autocommands are
      " duplicated if .vimrc gets sourced again, unless they are wrapped in an
      " augroup and the autocommands are cleared first using 'autocmd!'
      autocmd bufwritepost $MYVIMRC call OnSavingVimrc()
    augroup END
    
    " Avoid infinite loops
    if !exists("*OnSavingVimrc")
      function! OnSavingVimrc()
        " Clear previous mappings, they don't go away automatically when sourcing vimrc
        mapclear
        echo "Sourcing Vimrc after saving it"
        source $MYVIMRC
      endfunction
    endif
    

提交回复
热议问题