I'm experiencing a very sluggish startup time with vim as well as other unrelated programs ever since I logged out and logged back in the last time. Following is the startuptime log for vim:
自从上次退出并重新登录以来,我在vim和其他不相关的程序上的启动时间非常缓慢。以下是vim的startuptime日志:
> times in msec clock self+sourced self: sourced script clock
> elapsed: other lines
>
> 000.005 000.005: --- VIM STARTING ---
> 000.073 000.068: Allocated generic buffers
> 000.168 000.095: locale set
> 000.180 000.012: GUI prepared
> 000.181 000.001: clipboard setup
> 000.188 000.007: window checked
> 000.621 000.433: inits 1
> 000.626 000.005: parsing arguments
> 000.627 000.001: expanding arguments
> 000.637 000.010: shell init
> 000.909 000.272: Termcap init
> 000.942 000.033: inits 2
> 001.031 000.089: init highlight
> 023.418 000.234 000.234: sourcing /grid/common/pkgs/vim/v7.3/share/vim/vim73/syntax/syncolor.vim
> 023.543 001.811 001.577: sourcing /grid/common/pkgs/vim/v7.3/share/vim/vim73/syntax/synload.vim
> 044.397 015.231 015.231: sourcing /grid/common/pkgs/vim/v7.3/share/vim/vim73/filetype.vim
> 044.449 025.111 008.069: sourcing /grid/common/pkgs/vim/latest/share/vim/vim73/syntax/syntax.vim
> 052.532 000.199 000.199: sourcing /grid/common/pkgsData/vim-v7.3/Linux/RHEL4.0-2007-x86_64/share/vim/vim73/syntax/nosyntax.vim
> 059.858 000.175 000.175: sourcing /grid/common/pkgs/vim/v7.3/share/vim/vim73/syntax/syncolor.vim
> 059.966 003.842 003.667: sourcing /grid/common/pkgs/vim/v7.3/share/vim/vim73/syntax/synload.vim
> 060.002 010.259 006.218: sourcing /grid/common/pkgs/vim/v7.3/share/vim/vim73/syntax/syntax.vim
> 069.085 000.178 000.178: sourcing /grid/common/pkgs/vim/v7.3/share/vim/vim73/syntax/syncolor.vim
> 072.326 000.173 000.173: sourcing /grid/common/pkgs/vim/v7.3/share/vim/vim73/syntax/syncolor.vim
> 076.317 000.175 000.175: sourcing /grid/common/pkgs/vim/v7.3/share/vim/vim73/syntax/syncolor.vim
> 076.477 013.311 012.785: sourcing /grid/common/pkgs/vim/v7.3/share/vim/vim73/colors/desert.vim
> 079.768 000.019 000.019: sourcing /grid/common/pkgs/vim/v7.3/share/vim/vim73/filetype.vim
> 080.322 065.921 017.221: sourcing $HOME/.vimrc
> 080.330 013.378: sourcing vimrc file(s)
> 106.526 000.376 000.376: sourcing /home/haitham/.vim/plugin/genutils.vim
> 111.139 001.435 001.435: sourcing /home/haitham/.vim/plugin/multiselect.vim
> 113.534 000.147 000.147: sourcing /home/haitham/.vim/plugin/omap-param.vim
> 119.245 000.073 000.073: sourcing /home/haitham/.vim/plugin/qfixtoggle.vim
> 122.821 000.696 000.696: sourcing /home/haitham/.vim/plugin/surround.vim
> 172.247 000.098 000.098: sourcing /grid/common/pkgs/vim/v7.3/share/vim/vim73/plugin/getscriptPlugin.vim
> 176.387 000.252 000.252: sourcing /grid/common/pkgs/vim/v7.3/share/vim/vim73/plugin/gzip.vim
> 179.876 000.183 000.183: sourcing /grid/common/pkgs/vim/v7.3/share/vim/vim73/plugin/matchparen.vim
> 182.748 000.620 000.620: sourcing /grid/common/pkgs/vim/v7.3/share/vim/vim73/plugin/netrwPlugin.vim
> 186.171 000.051 000.051: sourcing /grid/common/pkgs/vim/v7.3/share/vim/vim73/plugin/rrhelper.vim
> 189.739 000.046 000.046: sourcing /grid/common/pkgs/vim/v7.3/share/vim/vim73/plugin/spellfile.vim
> 193.406 000.195 000.195: sourcing /grid/common/pkgs/vim/v7.3/share/vim/vim73/plugin/tarPlugin.vim
> 199.206 000.060 000.060: sourcing /grid/common/pkgs/vim/v7.3/share/vim/vim73/plugin/tohtml.vim
> 202.299 000.152 000.152: sourcing /grid/common/pkgs/vim/v7.3/share/vim/vim73/plugin/vimballPlugin.vim
> 205.345 000.147 000.147: sourcing /grid/common/pkgs/vim/v7.3/share/vim/vim73/plugin/zipPlugin.vim
> 205.394 120.533: loading plugins
> 12343.581 12138.187: inits 3
> 12349.592 006.011: reading viminfo
> 18421.239 6071.647: setup clipboard
> 18421.264 000.025: setting raw mode
> 18421.270 000.006: start termcap
> 18421.293 000.023: clearing screen
> 18421.504 000.211: opening buffers
> 18421.564 000.060: BufEnter autocommands
> 18421.566 000.002: editing files in windows
> 18425.833 004.267: VimEnter autocommands
> 18425.835 000.002: before starting main loop
> 18426.587 000.752: first screen update
> 18428.334 001.747: --- VIM STARTED ---
Apparently the biggest components are "inits 3" and "setup clipboard".
显然,最大的组件是“inits 3”和“安装剪贴板”。
Any clues what to do about it?
有什么线索吗?
Thanks!
谢谢!
1 个解决方案
#1
55
setup clipboard
First, try running Vim with the following command:
首先,尝试使用以下命令运行Vim:
$ vim -X
You can try using the -X --startuptime <file>
options together to see if the "setup clipboard" component is still slow.
您可以尝试使用-X -startuptime <文件> 选项,以查看“设置剪贴板”组件是否仍然缓慢。
If -X
helps, you can get the same effect by adding the following line to your vimrc file:
如果-X有帮助,您可以在vimrc文件中添加以下一行:
set clipboard=exclude:.*
Explanation
If this helps what is happening is that on startup Vim is trying to connect to an X server to allow it to use the clipboard. The -X
option tells Vim to not try connecting to the X server. From :help -X
如果这帮助了正在发生的事情,那么在启动Vim时,Vim正在尝试连接到一个X服务器,以允许它使用剪贴板。-X选项告诉Vim不要尝试连接到X服务器。来自:帮助- x
-X Do not try connecting to the X server to get the current
window title and copy/paste using the X clipboard. This
avoids a long startup time when running Vim in a terminal
emulator and the connection to the X server is slow.
See --startuptime to find out if affects you.
Only makes a difference on Unix or VMS, when compiled with the
+X11 feature. Otherwise it's ignored.
To disable the connection only for specific terminals, see the
'clipboard' option.
When the X11 Session Management Protocol (XSMP) handler has
been built in, the -X option also disables that connection as
it, too, may have undesirable delays.
The clipboard option can be used to achieve the same thing more permanently via your vimrc file. From :help 'clipboard'
剪贴板选项可以通过vimrc文件更持久地实现相同的功能。来自:帮助“剪贴板”
To never connect to the X server use: exclude:.* This has the same effect as using the -X argument. Note that when there is no connection to the X server the window title won't be restored and the clipboard cannot be accessed.
永远不要连接到X服务器使用:排除:。*这与使用-X参数具有相同的效果。注意,当没有与X服务器的连接时,窗口标题将不会被恢复,剪贴板将无法被访问。
The clipboard=exclude:.*
option can be refined to only work with particular terminals, if you want Vim to connect to the X server in some instances. Check out :help 'clipboard'
for more on this.
剪贴板=排除:。如果您希望Vim在某些实例中连接到X服务器,那么可以将选项细化为只对特定的终端有效。查看:帮助“剪贴板”更多关于这个。
For me, this problem was happening because I had "X11 Forwarding" enabled on my ssh client but did not always have an X Server running on the ssh client machine.
对我来说,出现这个问题是因为我在ssh客户机上启用了“X11转发”,但在ssh客户机上并不总是运行X服务器。
When I have an X server running on the target machine, Vim is much faster starting up (though still a bit slow).
当我在目标机器上运行一个X服务器时,Vim的启动速度要快得多(尽管仍然有点慢)。
In this setup, I want to maintain the X11 Forwarding, but do not need Vim to use the X clipboard, so I added the set clipboard=exclude:.*
line to my vimrc. Now Vim startup is quick for me once more.
在这个设置中,我想维护X11转发,但是不需要Vim来使用X剪贴板,所以我添加了set剪贴板=exclude:。到我的vimrc。现在Vim的初创公司又快给我了。
inits 3
You seem to have already eliminated your plugins/customisations as a possible cause by trying vim -u NONE
(and you said your vimrc was empty).
您似乎已经通过尝试vim -u NONE(并且您说您的vimrc是空的)消除了您的插件/定制。
I am not familiar with this issue, but as suggested above, it might be to do with your viminfo file.
我不熟悉这个问题,但是如上所述,它可能与您的viminfo文件有关。
You can determine whether this is the case by starting Vim with the following command:
您可以通过以下命令启动Vim来确定这种情况是否存在:
$ vim -i NONE
According to :help slow-start
:
据:帮助慢启动:
If you have "viminfo" enabled, the loading of the viminfo file may take a while. You can find out if this is the problem by disabling viminfo for a moment (use the Vim argument "-i NONE"). Try reducing the number of lines stored in a register with ":set viminfo='20,<50,s10".
如果启用了“viminfo”,则可能需要一段时间才能加载viminfo文件。通过禁用viminfo一段时间(使用Vim参数“- NONE”),您可以发现这是否是问题所在。尝试减少存储在寄存器中的行数,如“:set viminfo='20,<50,s10”。
#1
55
setup clipboard
First, try running Vim with the following command:
首先,尝试使用以下命令运行Vim:
$ vim -X
You can try using the -X --startuptime <file>
options together to see if the "setup clipboard" component is still slow.
您可以尝试使用-X -startuptime <文件> 选项,以查看“设置剪贴板”组件是否仍然缓慢。
If -X
helps, you can get the same effect by adding the following line to your vimrc file:
如果-X有帮助,您可以在vimrc文件中添加以下一行:
set clipboard=exclude:.*
Explanation
If this helps what is happening is that on startup Vim is trying to connect to an X server to allow it to use the clipboard. The -X
option tells Vim to not try connecting to the X server. From :help -X
如果这帮助了正在发生的事情,那么在启动Vim时,Vim正在尝试连接到一个X服务器,以允许它使用剪贴板。-X选项告诉Vim不要尝试连接到X服务器。来自:帮助- x
-X Do not try connecting to the X server to get the current
window title and copy/paste using the X clipboard. This
avoids a long startup time when running Vim in a terminal
emulator and the connection to the X server is slow.
See --startuptime to find out if affects you.
Only makes a difference on Unix or VMS, when compiled with the
+X11 feature. Otherwise it's ignored.
To disable the connection only for specific terminals, see the
'clipboard' option.
When the X11 Session Management Protocol (XSMP) handler has
been built in, the -X option also disables that connection as
it, too, may have undesirable delays.
The clipboard option can be used to achieve the same thing more permanently via your vimrc file. From :help 'clipboard'
剪贴板选项可以通过vimrc文件更持久地实现相同的功能。来自:帮助“剪贴板”
To never connect to the X server use: exclude:.* This has the same effect as using the -X argument. Note that when there is no connection to the X server the window title won't be restored and the clipboard cannot be accessed.
永远不要连接到X服务器使用:排除:。*这与使用-X参数具有相同的效果。注意,当没有与X服务器的连接时,窗口标题将不会被恢复,剪贴板将无法被访问。
The clipboard=exclude:.*
option can be refined to only work with particular terminals, if you want Vim to connect to the X server in some instances. Check out :help 'clipboard'
for more on this.
剪贴板=排除:。如果您希望Vim在某些实例中连接到X服务器,那么可以将选项细化为只对特定的终端有效。查看:帮助“剪贴板”更多关于这个。
For me, this problem was happening because I had "X11 Forwarding" enabled on my ssh client but did not always have an X Server running on the ssh client machine.
对我来说,出现这个问题是因为我在ssh客户机上启用了“X11转发”,但在ssh客户机上并不总是运行X服务器。
When I have an X server running on the target machine, Vim is much faster starting up (though still a bit slow).
当我在目标机器上运行一个X服务器时,Vim的启动速度要快得多(尽管仍然有点慢)。
In this setup, I want to maintain the X11 Forwarding, but do not need Vim to use the X clipboard, so I added the set clipboard=exclude:.*
line to my vimrc. Now Vim startup is quick for me once more.
在这个设置中,我想维护X11转发,但是不需要Vim来使用X剪贴板,所以我添加了set剪贴板=exclude:。到我的vimrc。现在Vim的初创公司又快给我了。
inits 3
You seem to have already eliminated your plugins/customisations as a possible cause by trying vim -u NONE
(and you said your vimrc was empty).
您似乎已经通过尝试vim -u NONE(并且您说您的vimrc是空的)消除了您的插件/定制。
I am not familiar with this issue, but as suggested above, it might be to do with your viminfo file.
我不熟悉这个问题,但是如上所述,它可能与您的viminfo文件有关。
You can determine whether this is the case by starting Vim with the following command:
您可以通过以下命令启动Vim来确定这种情况是否存在:
$ vim -i NONE
According to :help slow-start
:
据:帮助慢启动:
If you have "viminfo" enabled, the loading of the viminfo file may take a while. You can find out if this is the problem by disabling viminfo for a moment (use the Vim argument "-i NONE"). Try reducing the number of lines stored in a register with ":set viminfo='20,<50,s10".
如果启用了“viminfo”,则可能需要一段时间才能加载viminfo文件。通过禁用viminfo一段时间(使用Vim参数“- NONE”),您可以发现这是否是问题所在。尝试减少存储在寄存器中的行数,如“:set viminfo='20,<50,s10”。