我的Vim配置文件越来越大了(15 KB+)。为了避免在启动时加载更多的文件而使Vim变慢,我尽量不引入更多的插件和文件。出于同样的目的,我只使用必要的插件,并尽可能减少插件数量。
因此,在我的.vimrc文件中,我有以下这些行:
autocmd FileType python setlocal expandtab shiftwidth=4 tabstop=4 softtabstop=4
autocmd FileType python setlocal textwidth=78
autocmd FileType python match ErrorMsg '\%>80v.\+'
autocmd FileType python inoremap <F5> <esc>:upd\|!python %<cr>
autocmd FileType python nnoremap <F5> :upd\|!python %<cr>
autocmd FileType python nnoremap <leader>8 :w\|call Flake8()<cr>
autocmd FileType python setlocal formatoptions-=t
autocmd BufWritePost *.py call Flake8()
现在我看到前7行,所有行都共同有autocmd FileType python
这句话。所以我的想法是,如果我们设法将所有这些单词替换为更短的内容,那么Vim启动的速度就会更快。但我不知道该怎么做。
我们能否将它们分组?如何分组?还有其他的方法吗?
:%d
是清理您的vimrc文件的最佳方法。或者,:new|saveas! $MYVIMRC
也是相当有效的。 - sehe:help autocmd-groups
。 - sehe