Thursday, October 08, 2009

Slow vim startup -- solved

I've had some frustration due to slow vim startup.

time vim -c 'q'

real 0m6.138s
user 0m0.096s
sys 0m0.024s

Found the solution though. a blog post at samdorr.net says to use -X.

So now I have two new aliases in ~/.bashrc

alias vi="/usr/bin/vi -X"
alias vim="/usr/bin/vim -X"

I was a little confused because the slowness was there in screen, but when I opened a new terminal, there was no slowness (even without the aliases). I think it's because I've restarted X since I started screen. So $DISPLAY in the screen sessions is :0.0, but possibly there's some other X authentication cookies that refer to the old X session. Ok, I just looked, there's an XDG_SESSION_COOKIE, maybe that's it, or if not, something similar. So the X authentication still succeeds, but only after a timeout.

The poster at samdorr had a different problem. His server probably didn't have X at all, or maybe vim is trying to connect via ssh X forwarding, back to his graphical terminal :-). But the solution he gives is an axe that solves my problem too since I don't need vim to talk to X at all.

Hmmm, someday I'll just need to catch up to the modern world and use gvim, and probably syntax highlighting even :-).

1 comment:

xiaq said...

Hi,

This is actually a GNU screen's issue (certain environment variables failed to get updated). I don't know how to fix (instead of working around) this in screen, but I use tmux, which has a "update-environment" option. I just use

set -ga update-environment " XDG_SESSION_COOKIE DBUS_SESSION_BUS_ADDRESS SESSION_MANAGER"

(-g: global; -a: append) and the problem is fully resolved. Hope will be helpful for you :)