I had today a very weird situation.
From my laptop, I ssh to another system, and from there to yet another.
On this final system I noticed that vim starts relatively slow. i.e. this command:
time vim -u /dev/null -c “:q"
returned time in around 3.5 seconds, while on my laptop (which is much less powerful) it is:
=> time vim -u /dev/null -c ":q"
real 0m0.073s
user 0m0.056s
sys 0m0.016s
I tried to debug the situation, and it got weirder. If I did “su – another_user" (on the final system) – it became fast. What's more: if I did su – depesz (my account) back – vim was still fast!
After some debugging it occurred to me: I have automatic X11 forwarding turned on. I checked – and yes, in the shell that vim starts slowly, i had “DISPLAY" variable, set to localhost:10.0!
Quick unset DISPLAY, and suddenly vim starts 0.027s!
Lesson for future – do not use automatic X11 forwarding for long-distance ssh connections, or make sure you run vim with “-X" option.
Later I learned why it tries X11 connection – to get access to X copy/paste buffer (available as * register). Nice feature, but with quite problematic side effects.