[vim/vim] [netrw v162h] gx does not bring up the url in a browser (#1386)

298 views
Skip to first unread message

xc1427

unread,
Jan 15, 2017, 7:53:25 PM1/15/17
to vim/vim, Subscribed

Environment:
gvim 8.0.45 64bit on windows 10.
netrw v162h

Description:
gx (|netrw-gx|) on an url downloaded the file using curl instead of bringing up the url in a browser.
In addition, I didn't set g:netrw_gx and g:netrw_browsex_viewer.


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub

cecamp

unread,
Jan 15, 2017, 10:31:13 PM1/15/17
to vim/vim, Subscribed

Please try the directions in :help netrw-debug. I don't have a windows 10 system myself to work with.

xc1427

unread,
Jan 16, 2017, 5:06:18 AM1/16/17
to vim/vim, Subscribed

cecamp commented 7 hours ago


Please try the directions in :help netrw-debug. I don't have a windows 10 system myself to work with.

FYI, I tested also on the pc of my work, which is a windows 7. The same problem there. I will try the debug later.

xc1427

unread,
Mar 5, 2017, 12:25:21 AM3/5/17
to vim/vim, Subscribed

@cecamp I have tried netrw-debug.
I activated Decho and I found the problem is from netrw.
Actually, gx in visual mode did bring up the url in browser. Then I compared the debug information between gx in normal mode and visual mode.

In visual mode:
netrw#BrowseXVis calls netrw#CheckIfRemote without parameter, making remote=0. As a result, fname is assigned by a:fname, which is the URL.

In normal mode:
On the contrary, netrw#CheckIfRemote is called with parameter, making remote=1. In consequence, netrw#BrowseX creates a local copy (netrw.vim 162j :5087), making fname is renamed by a tmp file.

Solution
The simple solution is to remove the parameter of CheckIfRemote at line 84 in file netrwPlugin.vim.

Debug info
I paste below the debug information when url http://chez-syl.fr/2012/03/bonnes-pratiques-jquery/ is clicked.

  • Debug normal gx
 netrw#CheckIfRemote() a:0=1 {
|curfile<http://chez-syl.fr/2012/03/bonnes-pratiques-jquery/>
|return netrw#CheckIfRemote 1 }
netrw#BrowseX(fname<http://chez-syl.fr/2012/03/bonnes-pratiques-jquery/> remote=1) {
|remote: a:remote=1: create a local copy of <http://chez-syl.fr/2012/03/bonnes-pratiques-jquery/> ~53
|basename<chez-syl> ~59
|newname <C:/Users/cxi/AppData/Local/Temp/chez-syl.tmp> ~60
|newname=C:/Users/cxi/AppData/Local/Temp/chez-syl.tmp
|fname<C:/Users/cxi/AppData/Local/Temp/chez-syl.tmp> ~79
|exten<fr/2012/03/bonnes-pratiques-jquery/> netrwFileHandlers#NFH_fr/2012/03/bonnes-pratiques-jquery/():exists=0 ~80
|windows ~134
|return netrw#BrowseX }
  • Debug visual gx
netrw#BrowseXVis() {
|@@<http://chez-syl.fr/2012/03/bonnes-pratiques-jquery/> ~4
|netrw#CheckIfRemote() a:0=0 {
||curfile<Git_repo/tabcdn_simulmo/README.md>
||return netrw#CheckIfRemote 0 }
|netrw#BrowseX(fname<http://chez-syl.fr/2012/03/bonnes-pratiques-jquery/> remote=0) {
||fname<http://chez-syl.fr/2012/03/bonnes-pratiques-jquery/> ~79
||exten<fr/2012/03/bonnes-pratiques-jquery/> netrwFileHandlers#NFH_fr/2012/03/bonnes-pratiques-jquery/():exists=0 ~80
||windows ~134
||return netrw#BrowseX }
|return netrw#BrowseXVis }

Chen XI

unread,
Apr 16, 2017, 2:04:31 PM4/16/17
to vim/vim, Subscribed

News on version v162k:
gx(visual) now works the same way as gx(normal). So gx(visual) does not either bring URL in a browser if your highlight an URL like http://xxx.

This is because the function netrw#BrowseXVis, which is executed by gx(visual), is slightly modified in v162k:

" See file vimfiles/autoload/netrw.vim:5327
call netrw#BrowseX(@@,netrw#CheckIfRemote(@@))

which was called without parameter in previous version:

call netrw#BrowseX(@@,netrw#CheckIfRemote())

cecamp

unread,
Apr 16, 2017, 6:09:18 PM4/16/17
to vim/vim, Subscribed
Chen XI wrote:
>
> *News on version v162k:*
> gx(visual) now works the same way as gx(normal). So gx(visual) *does
> not either* bring URL in a browser if your highlight an URL like
> /http://xxx/.
>
> This is because the function |netrw#BrowseXVis|, which is executed by
> gx(visual), is slightly modified in v162k:
>
> " See file vimfiles/autoload/netrw.vim:5327
> call netrw#BrowseX(@@,netrw#CheckIfRemote(@@))
>
> which was called *without parameter* in previous version:
>
> call netrw#BrowseX(@@,netrw#CheckIfRemote())
>
That's because the "without parameter" call was incorrect.

gx is intended to handle urls like http://xxx.whatever/ (note that
trailing slash), and it needs to know whether the call is local or remote.
You should get a message: ***error*** not a netrw-style url; netrw uses
protocol://[user@]hostname[:port]/[path])

Chip Campbell

Chen XI

unread,
Apr 16, 2017, 10:53:07 PM4/16/17
to vim/vim, Subscribed

That's because the "without parameter" call was incorrect.

I agree with you. And I think gx is meant to handler other url-like string such as ftp, scp, etc as well.

You should get a message: error not a netrw-style url; netrw uses


protocol://[user@]hostname[:port]/[path])

I didn't get this error message but some bizarre split window behavior . This is another story about netrw#ErrorMsg() not working correctly. Nevertheless, this message should have been printed.

gx is intended to handle urls like http://xxx.whatever/ (note that
trailing slash), and it needs to know whether the call is local or remote.

The question is how netrw should handle a http(s):// string. The actual behavior on win10 is that it considers http(s):// a remote call, then downloads the web page, renames it as xxxx.tmp and tries to open this tmp file. But this behavior does not make any sense. While, if http(s):// is seen as local, then it can be directly handled by a browser and I think that makes sense.

I think some finer condition test should be written inside the netrw#BrowseX function.

Anton Styagun

unread,
Nov 24, 2017, 9:23:31 AM11/24/17
to vim/vim, Subscribed

I see the problem on macOS as well:

netrw

Environment:

  • macOS High Sierra 10.13.1 (17B48)
  • MacVim 8.0.1272 (142)
  • netRW v162: Sep 19, 2016

mmikeww

unread,
Dec 12, 2017, 7:03:36 PM12/12/17
to vim/vim, Subscribed

in Gvim7.4 on Windows, pressing gx over a URL would successfully open Chrome. First I would get a quick cmd window that would disappear and then the browser would open

in Gvim8, I'm seeing the cmd window open and close, and then quickly seeing this error in the Vim command line:

"NetrwMessage" --No lines in buffer--

and then the error disappears and it opens up a horizontal split

K.Takata

unread,
Dec 13, 2017, 3:36:05 AM12/13/17
to vim/vim, Subscribed

I personally use open-browser.vim for this purpose.
I think it is stable and tested well. Moreover, it works on many platforms including macOS, Linux, Windows, etc.

pinggit

unread,
Jan 13, 2018, 5:24:10 PM1/13/18
to vim/vim, Subscribed

is there a fix to this issue yet?
I just tested the fresh new cygwin install that contains vim8. seem issue and no luck.
will have to try the open-browser.vim plugin...

Jesse Atkinson

unread,
May 29, 2018, 2:42:10 PM5/29/18
to vim/vim, Subscribed

I'm still getting this issue. I'd love to not have to not install yet another plugin.

I'm willing to help diagnose and code to help fix the issue.

cecamp

unread,
May 31, 2018, 1:09:10 PM5/31/18
to vim/vim, Subscribed
Jesse Atkinson wrote:
>
> I'm still getting this issue. I'd love to not have to not install yet
> another plugin.
>
> I'm willing to help diagnose and code to help fix the issue.
>
>
I don't see this problem, but then I don't have windows 10.

May I suggest you look at :help netrw-debug for directions on how to
debug netrw.

Regards,
C Campbell

Ankit Jha

unread,
Aug 13, 2019, 2:50:43 PM8/13/19
to vim/vim, Subscribed

Is there any work around for this other than installing some plugin ?
May be some flag value set in .vimrc

cecamp

unread,
Aug 13, 2019, 2:57:06 PM8/13/19
to vim/vim, Subscribed

It would help if a volunteer would take the advice in :help netrw-debug . I don't have a Mac and so can't really debug this without such help.

Jesse Atkinson

unread,
Aug 13, 2019, 2:57:27 PM8/13/19
to vim/vim, Subscribed

I am still getting this issue. gx does not always open links in the browser. Seems dependent on what file type I'm in.

Christian Brabandt

unread,
Aug 14, 2019, 3:16:03 AM8/14/19
to vim/vim, Subscribed

@jsatk if you want this fixed, follow the advice from #1386 (comment)

Christian Brabandt

unread,
Aug 14, 2019, 3:17:20 AM8/14/19
to vim/vim, Subscribed

closing this in favor of #4738 (which seems to be a duplicate).

Christian Brabandt

unread,
Aug 14, 2019, 3:17:22 AM8/14/19
to vim/vim, Subscribed

Closed #1386.

Reply all
Reply to author
Forward
0 new messages