Ubuntu 桌面上的 vim 非常滞后且缓慢,但 vim.tiny 很好

Ubuntu 桌面上的 vim 非常滞后且缓慢,但 vim.tiny 很好

最近我将工作环境从 Windows 更改为 Ubuntu Desktop,遇到了一个从未遇到过的奇怪问题。

我发现 Ubuntu 桌面的 gnome 终端上的 vim 相当慢且滞后,我发现如果改回 vim.tiny,就没问题了。

我经常在 Linux 服务器(通常通过 ssh)、Windows、macos 上使用 vim,从未发现 vim 滞后。

滞后和缓慢的感觉很难表达,H,J,K,L移动光标没问题,但I(插入)和ESC有明显的延迟。

答案1

如果你还想检查 vim 的启动时间,你可以使用它--startuptime创建一个文件,显示每个插件(和许多其他进程)为启动时间增加了多少时间:

vim --startuptime profile_vim_startup.vim

将创建一个名为“profile_vim_startup.vim”的文件

举个例子,我的文件末尾显示 YouCompleteMe 插件大约需要 100 毫秒才能加载:

times in msec
 clock   self+sourced   self:  sourced script
 clock   elapsed:              other lines
   .        .           .
   .        .           .
   .        .           .
g62.216  000.010: start termcap
062.238  000.022: clearing screen
062.614  000.376: opening buffers
062.648  000.034: BufEnter autocommands
062.650  000.002: editing files in windows
064.780  000.578  000.578: sourcing /home/mattb/.vim/bundle/YouCompleteMe/autoload/youcompleteme.vim
157.396  094.168: VimEnter autocommands
157.401  000.005: before starting main loop
157.892  000.491: first screen update
157.893  000.001: --- VIM STARTED ---

我的完整文件(100 行)如下:

times in msec
 clock   self+sourced   self:  sourced script
 clock   elapsed:              other lines

000.003  000.003: --- VIM STARTING ---
000.059  000.056: Allocated generic buffers
000.086  000.027: locale set
000.090  000.004: GUI prepared
000.092  000.002: clipboard setup
000.094  000.002: window checked
000.322  000.228: inits 1
000.337  000.015: parsing arguments
000.337  000.000: expanding arguments
000.350  000.013: shell init
003.271  002.921: xsmp init
003.442  000.171: Termcap init
003.474  000.032: inits 2
003.599  000.125: init highlight
003.908  000.220  000.220: sourcing /usr/share/vim/vim82/debian.vim
004.496  000.479  000.479: sourcing /usr/share/vim/vim82/syntax/syncolor.vim
004.566  000.586  000.107: sourcing /usr/share/vim/vim82/syntax/synload.vim
008.489  003.893  003.893: sourcing /usr/share/vim/vim82/filetype.vim
008.516  004.572  000.093: sourcing /usr/share/vim/vim82/syntax/syntax.vim
008.529  004.905  000.113: sourcing $VIM/vimrc
008.583  000.007  000.007: sourcing /usr/share/vim/vim82/filetype.vim
008.637  000.024  000.024: sourcing /usr/share/vim/vim82/ftplugin.vim
008.689  000.020  000.020: sourcing /usr/share/vim/vim82/indent.vim
008.879  000.130  000.130: sourcing /home/mattb/.vim/bundle/Vundle.vim/autoload/vundle.vim
009.042  000.103  000.103: sourcing /home/mattb/.vim/bundle/Vundle.vim/autoload/vundle/config.vim
012.043  000.006  000.006: sourcing /usr/share/vim/vim82/filetype.vim
012.228  000.005  000.005: sourcing /usr/share/vim/vim82/ftplugin.vim
012.404  000.005  000.005: sourcing /usr/share/vim/vim82/indent.vim
013.428  000.227  000.227: sourcing /usr/share/vim/vim82/pack/dist/opt/matchit/plugin/matchit.vim
013.476  000.516  000.289: sourcing /usr/share/vim/vim82/macros/matchit.vim
013.588  001.657  001.125: sourcing /home/mattb/.vim/bundle/vim-sensible/plugin/sensible.vim
018.137  000.168  000.168: sourcing /usr/share/vim/vim82/syntax/nosyntax.vim
018.439  000.089  000.089: sourcing /usr/share/vim/vim82/syntax/syncolor.vim
018.595  000.355  000.266: sourcing /usr/share/vim/vim82/syntax/synload.vim
018.614  000.671  000.148: sourcing /usr/share/vim/vim82/syntax/syntax.vim
022.585  000.116  000.116: sourcing /usr/share/vim/vim82/syntax/syncolor.vim
023.185  000.110  000.110: sourcing /usr/share/vim/vim82/syntax/syncolor.vim
023.529  000.107  000.107: sourcing /usr/share/vim/vim82/syntax/syncolor.vim
025.434  002.721  002.504: sourcing /home/mattb/.vim/bundle/vim-colorschemes/colors/seoul256.vim
025.446  003.198  000.361: sourcing /home/mattb/.vim/bundle/vim-colorschemes/colors/seoul256-light.vim
026.373  017.826  012.016: sourcing $HOME/.vimrc
026.376  000.046: sourcing vimrc file(s)
026.746  000.172  000.172: sourcing /home/mattb/.vim/bundle/vim-commentary/plugin/commentary.vim
026.810  000.009  000.009: sourcing /home/mattb/.vim/bundle/vim-sensible/plugin/sensible.vim
027.212  000.365  000.365: sourcing /home/mattb/.vim/bundle/vim-surround/plugin/surround.vim
027.502  000.236  000.236: sourcing /home/mattb/.vim/bundle/ReplaceWithRegister/plugin/ReplaceWithRegister.vim
027.716  000.169  000.169: sourcing /home/mattb/.vim/bundle/vim-indent-object/plugin/indent-object.vim
027.947  000.054  000.054: sourcing /home/mattb/.vim/bundle/ultisnips/autoload/UltiSnips/map_keys.vim
028.015  000.249  000.195: sourcing /home/mattb/.vim/bundle/ultisnips/plugin/UltiSnips.vim
028.225  000.163  000.163: sourcing /home/mattb/.vim/bundle/vim-tmux-navigator/plugin/tmux_navigator.vim
028.883  000.615  000.615: sourcing /home/mattb/.vim/bundle/vim-indentwise/plugin/indentwise.vim
029.048  000.117  000.117: sourcing /home/mattb/.vim/bundle/vim-slime/plugin/slime.vim
029.594  000.506  000.506: sourcing /home/mattb/.vim/bundle/fzf/plugin/fzf.vim
030.358  000.710  000.710: sourcing /home/mattb/.vim/bundle/fzf.vim/plugin/fzf.vim
030.636  000.228  000.228: sourcing /home/mattb/.vim/bundle/traces.vim/plugin/traces.vim
030.831  000.060  000.060: sourcing /home/mattb/.vim/bundle/vim-mundo/autoload/mundo/util.vim
031.019  000.338  000.278: sourcing /home/mattb/.vim/bundle/vim-mundo/plugin/mundo.vim
033.256  002.191  002.191: sourcing /home/mattb/.vim/bundle/vim-fugitive/plugin/fugitive.vim
055.155  009.211  009.211: sourcing /home/mattb/.vim/bundle/vim-unimpaired/plugin/unimpaired.vim
055.683  000.445  000.445: sourcing /home/mattb/.vim/bundle/YouCompleteMe/plugin/youcompleteme.vim
055.949  000.200  000.200: sourcing /home/mattb/.vim/bundle/vim-tmux-focus-events/plugin/tmux_focus_events.vim
056.059  000.045  000.045: sourcing /home/mattb/.vim/bundle/Tabmerge/plugin/Tabmerge.vim
056.300  000.202  000.202: sourcing /home/mattb/.vim/bundle/targets.vim/plugin/targets.vim
056.509  000.049  000.049: sourcing /usr/share/vim/vim82/plugin/getscriptPlugin.vim
056.691  000.170  000.170: sourcing /usr/share/vim/vim82/plugin/gzip.vim
056.858  000.155  000.155: sourcing /usr/share/vim/vim82/plugin/logiPat.vim
056.893  000.021  000.021: sourcing /usr/share/vim/vim82/plugin/manpager.vim
057.035  000.131  000.131: sourcing /usr/share/vim/vim82/plugin/matchparen.vim
057.473  000.424  000.424: sourcing /usr/share/vim/vim82/plugin/netrwPlugin.vim
057.522  000.027  000.027: sourcing /usr/share/vim/vim82/plugin/rrhelper.vim
057.558  000.020  000.020: sourcing /usr/share/vim/vim82/plugin/spellfile.vim
057.692  000.120  000.120: sourcing /usr/share/vim/vim82/plugin/tarPlugin.vim
057.797  000.085  000.085: sourcing /usr/share/vim/vim82/plugin/tohtml.vim
057.937  000.126  000.126: sourcing /usr/share/vim/vim82/plugin/vimballPlugin.vim
058.106  000.146  000.146: sourcing /usr/share/vim/vim82/plugin/zipPlugin.vim
058.179  000.015  000.015: sourcing /usr/share/vim/vim82/pack/dist/opt/matchit/plugin/matchit.vim
058.235  000.011  000.011: sourcing /home/mattb/.fzf/plugin/fzf.vim
058.242  014.195: loading plugins
058.293  000.051: loading packages
058.550  000.103  000.103: sourcing /home/mattb/.vim/bundle/ultisnips/after/plugin/UltiSnips_after.vim
058.671  000.275: loading after plugins
058.685  000.014: inits 3
059.101  000.416: reading viminfo
062.199  003.098: setup clipboard
062.206  000.007: setting raw mode
g62.216  000.010: start termcap
062.238  000.022: clearing screen
062.614  000.376: opening buffers
062.648  000.034: BufEnter autocommands
062.650  000.002: editing files in windows
064.780  000.578  000.578: sourcing /home/mattb/.vim/bundle/YouCompleteMe/autoload/youcompleteme.vim
157.396  094.168: VimEnter autocommands
157.401  000.005: before starting main loop
157.892  000.491: first screen update
157.893  000.001: --- VIM STARTED ---

答案2

更新:

出于绝望,我想为什么不从源代码编译 vim。所以我就这么做了,而且 vim 运行得很好。

git clone https://github.com/vim/vim.git
cd vim/src
make
make install 

遗憾的是,经过足够的搜索和尝试,普通的 vim 就是无法像 vim.tiny 那样流畅。

我猜测该问题具体与 Ubuntu 桌面上的 gnome-terminal 上的 vim 有关。

到目前为止,我别无选择,只能坚持使用 vim.tiny。

Ubuntu 桌面上的普通 vim 比较滞后,但如果你 ssh 到 Ubuntu 桌面机器,vim 就可以正常工作。

所以我高度怀疑该问题与 GUI 桌面或其他东西有关。

相关内容