0

I used Putty to remote to Linux machine, and when I use vim to open a file it always delays and display message PuTTY X11 proxy: unable to connect to forwarded X server: Network error: Connection refused. How can I fix it?

bertieb
  • 7,344
  • 36
  • 42
  • 54
Khong Son
  • 1
  • 1
  • As `vim` shouldn't require X server for anything, could it be that `vim` is actually an shell alias for some GUI enabled version of it? Please post the output of `alias vim`. You don't mention which distro is being used, but it also could be that the `vim` found in the path is a symbolic link to something else than the text-mode version, so please also post the output of `ls -la $(which vim)` – zagrimsan Sep 23 '15 at 10:17
  • 1
    @zagrimsan I'm sorry to have to contradict you, but Vim absolutely requires X server access in many circumstances. Most notably for the GUI, but even the console Vim can try to contact the X server for a number of things, such as handling X11 selection events, clientserver, etc. – Heptite Sep 23 '15 at 21:01
  • @zagrimsan: This is result of your command: lrwxrwxrwx 1 root root 21 Nov 1 2013 /usr/bin/vim -> /etc/alternatives/vim what's problem with vim version I use? – Khong Son Sep 24 '15 at 01:14
  • @Heptite I personally don't use `vim` so I thought it would be textmode-only and only the other derivatives like `gvim`, `vim-gnome`, `vim-gtk` etc need X. If that is the case, OP needs to set up X11 Forwarding with Putty with e.g. [XMing](http://superuser.com/q/592185/243625) or [otherwise](http://superuser.com/q/313421/243625) **or** configure `vim` so that it doesn't require X in which I'm sure you Heptite could help :) – zagrimsan Sep 24 '15 at 02:56

1 Answers1

0

You can either set up X forwarding, or give Vim an option not to try to contact the X server (note that it's an uppercase X):

vim -X

However, usually Vim does not try to connect to an X server unless it believes one is available; somehow your DISPLAY environmental variable is getting set somewhere.

Heptite
  • 19,383
  • 5
  • 58
  • 71