
Opening files the first time is very slow in vim. I made a vim --startuptime start.log .vimrc
. These are the TOP4 found in start.log
2075.385 1790.067: opening buffers
2200.133 124.203: BufEnter autocommands
117.800 082.955 062.110: sourcing $HOME/.vimrc
247.013 073.089 073.089: sourcing /home/fwagner/.vim/bundle/vim-fat-finger/plugin/fat-finger.vim
Is there a way to speed up the buffer opening?
Antwort1
Make sure your autocommands are grouped like this:
augroup EditVim
autocmd!
autocmd BufWritePost .vimrc source $MYVIMRC
autocmd FileType vim setlocal foldmethod=marker
augroup END
If your vimrc is being sourced multiple times for some reason and your autocommands are not cancelled with autocmd!
, your BufEnter commands will be registered again and again and vim will slow to a crawl. It's one of the (many) edge cases in vim.
Check out this chapter of Learn Vimscript the Hard Way by Steve Losh for more info.