Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vim 7.2 hangs on startup, "killall vim" fixes it

Tags:

vim

I just compiled vim 7.2 on a Linux server (in my user dir, since the server had vim 6 installed and I wanted to upgrade but do not have root privileges).

When I enter "vim", it hangs on startup without any response, but when I call "killall vim" from another ssh window, startup completes and vim seems to work fine after that. Why would that be, and how can I fix it?

Many thanks for your responses.

like image 679
Magnus Avatar asked Aug 21 '09 03:08

Magnus


3 Answers

Well, I found the answer:

:help -X

shows that Vim tries to connect to the X11 server on startup to get clipboard functionality and other stuff, which can lead to a "long startup time when running Vim in a terminal emulator and the connection to the X server is slow"

There are three ways to resolve this issue:

  1. Starting Vim with "vim -X" disables this X11 communication
  2. Calling "unset DISPLAY" also disables the X11 communication
  3. If Vim is compiled without the "+X11" feature, this communication will not take place

I went for "unset DISPLAY" since I've been getting other strange error messages, and now vim starts all but instantly. I also tested the -X parameter, which resolved the problem as well (even with the DISPLAY parameter still set).

like image 119
Magnus Avatar answered Oct 24 '22 00:10

Magnus


strace vim will probably tell you what's hanging it.

like image 28
Alex Martelli Avatar answered Oct 23 '22 23:10

Alex Martelli


Another common reason for vim hanging at startup is when it is trying to access GPM (ie: custom fonts, etc). In my case, I was having the same symptoms, but it ended up being a mouse-related issue with GPM.

Putting the following (from: http://www.linuxquestions.org/questions/slackware-14/vim-freeze-at-startup-when-in-ssh-session-856606/) in my .vimrc fixed the hang-on-startup issue with VIM.

" This section is bigger in my .vimrc, this is just an excerpt.
if has('gui_running')
  " Mouse on GUI comes handy.
  set mouse=a
else
  set mouse=
endif

Hope this helps other readers that come this way :)

like image 2
Cloud Avatar answered Oct 23 '22 23:10

Cloud