1

I used to use chromium before and then, I could press gx on an url and vim would open it in a new tab if a chromium instance was already running, otherwise create a new window.

But in firefox, when I press gx on an url, vim opens a new firefox instance that is not even signed into my firefox account.

How do I change the behavior of gx so that it opens a new tab of an already opened firefox instance?

N.B. The output of lsb_release -a is as follows.

enan@elariel:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 18.04.3 LTS
Release:    18.04
Codename:   bionic
5
  • 1
    The launch process is platform-dependent. What OS are you on?
    – B Layer
    Feb 29 '20 at 14:28
  • 1
    @BLayer, added OS info in edit. Thanks for helping.
    – kadekai
    Feb 29 '20 at 16:18
  • 1
    Mostly using Cygwin here now which has different process than pure *nix. I can tell you that the logic for launching external progs (e.g. browser) is in the function netrw#BrowseX in $VIMRUNTIME/autoload/netrw.vim (long function...scroll down a ways). Looks like xdgopen is used in some cases. Anyways, you might want to poke around there yourself...see if you see anything off.
    – B Layer
    Feb 29 '20 at 17:33
  • 1
    this depends on your desktop environment. I believe netrw does simply call xdg-open. What browser this finally opens depends on the default browser for your desktop environment. On XFCE, this uses e.g. exo-open. I suppose you have to configure it using some desktop files. (on my system, it opens URLs in a new tab of firefox). Feb 29 '20 at 21:40
  • @ChristianBrabandt, I just did exo-open "https://google.com" from my terminal. It opened in a new-tab. But vim doesn't do that. Something else is wrong. I'm looking through netrw.vim and its help docs(huge!) to see if I can find something. Will report back if I do.
    – kadekai
    Mar 1 '20 at 14:15
0

The issue was with how the Firefox profiles were set. When a command told it open a new tab, it checked for the default profile, and saw that no instance of it was opened, so opened a new instance. Firefox doesn't care that an instance of another profile was opened, because that profile isn't the default one.

So, you need to mark the profile you use as the default one. Go to about:profiles in Firefox and you'll see multiple profiles, one of which is marked as the default. You'll have to mark the profile you use as the default one. Now, it's hard to understand which profile is the one you use if there are more than three profiles. In that case, I suggest trial and error. Mark each one the default at a time and see if gx works properly or not.

Firefox Profiles

It may have been a bug with Firefox, because I haven't faced this issue after an update or two, and I have reinstalled OS several times so there is no way my settings of profile was unchanged.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.