6

I am using gvim 7.3.401 on archlinux. The shell command :!xdg-open http://www.vim.org doesn't open my default browser with that link. In fact, it appears to do nothing.

This works as expected within terminal vim

How can I make it work in gvim too?

Jeremy W
  • 3,629
  • 20
  • 35
Maxim Kim
  • 163
  • 5
  • Both work fine for me on a Fedora 11 system, in that they both open that URL in Konqueror, although they both print an error message like this one: "(25702)/ ClientApp::doIt: Creating ClientApp". Perhaps your environments differ between vim and gvim. Try executing ":!env > gvim_env" in gvim and ":!env > vim_env" in vim, then in the shell execute "vimdiff gvim_env vim_env" to see the differences. You may have to sort those files as well for the diff to make sense. – garyjohn Feb 06 '12 at 18:39
  • The only difference is vim_env has TERM=xterm, gvim_env TERM=dumb – Maxim Kim Feb 06 '12 at 19:47
  • It works on my debian squeeze box with gnome2, but not on my laptop with archlinux and gnome3 – Maxim Kim Feb 06 '12 at 20:02
  • I'm afraid I'm stumped then. Sorry I couldn't help. – garyjohn Feb 06 '12 at 20:46

2 Answers2

9

Try :!xdg-open http://www.vim.org &

I had the same issue until I saw how LaTeX-Box does it.

sappjw
  • 233
  • 1
  • 8
2

The issue here is that gvim does spawn a new, dummy terminal for each command and it apparently kills it after the command returns. So the:

:!xdg-open http://www.vim.org

returns immediately and apparently(*) the xdg-open internal asynchronous call to X gets terminated, while making the call go to background (as suggested by sappjw) doesn't:

:!xdg-open http://www.vim.org &

(*) - please correct me if I'm wrong

derenio
  • 121
  • 2