Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make the gx command work for URLs in Vim on XFCE4 Desktop?

Tags:

vim

With GVim on my Windows 7 system, if I press gx while the cursor is on an URL, it launches the URL in Firefox (my default browser on Windows).

However, when I do the same on my XFCE4 Desktop on Debian 8.3 Linux system, pressing gx does nothing at all.

I am using GVim (Vim 7.4) on both systems.

The :let g:netrw_browsex_viewer command returns E121: Undefined variable: g:netrw_browsex_viewer on both systems.

I tried entering the :let g:netrw_browsex_viewer= "xdg-open" command on the Linux system, but it didn't help at all.

I have two questions:

  1. Why does the gx command work for URLs on the Windows system but not on XFCE4 desktop on the Debian Linux system even though g:netrw_browsex_viewer is undefined in both?
  2. How can I make the gx command work for URLs on XFCE4 desktop on the Debian Linux system?
like image 306
Lone Learner Avatar asked Nov 20 '22 18:11

Lone Learner


1 Answers

Normally, the following command should work, and it does work when executing Vim 7.4.576 within Xfce terminal (xfce4-terminal 0.6.3).

:let g:netrw_browsex_viewer="xdg-open"

But the above command does not work in GVim 7.4.576 in Xfce 4.10 due to Bug 12251 - exo-open URL does nothing from gvim.

A workaround suggested by Christian Brabandt that works for me is the following.

:let g:netrw_browsex_viewer="setsid xdg-open"
like image 179
Lone Learner Avatar answered Jan 11 '23 22:01

Lone Learner