gx strange behavior

40 views
Skip to first unread message

Manfred Lotz

unread,
Apr 5, 2020, 4:48:08 AM4/5/20
to vim...@googlegroups.com
Hi all,
I have Fedora 31 and Fedora 32. Happens on both systems.

I want to open an URL in my browser and type `gx` when the cursor is
over an URL in vim resp. gvim


Doing this for example in an markdown document it works fine for vim but
nothing happens when doing the same in gvim.

When debugging (i.e. starting vim resp. gvim with `-V9vim.log`) I see:

line 2: sourcing "/usr/share/vim/vim82/autoload/netrw.vim"
finished sourcing /usr/share/vim/vim82/autoload/netrw.vim
continuing in <SNR>67_VersionAwareNetrwBrowseX
:!setsid xdg-open 'https://realpython.com/python-data-types/'>/dev/null
2>&1

Calling shell to execute: "setsid xdg-open
'https://realpython.com/python-data-types/'>/dev/null 2>&1"


Any idea how to find out why gvim behaves differently?


--
Manfred

Manfred Lotz

unread,
Apr 5, 2020, 5:21:25 AM4/5/20
to vim...@googlegroups.com
I found something. When invoking `:sh` in vim I get a clean zsh shell.
When invoking `:sh` in gvim I get a zsh shell with strange control
characters in the prompt.

Current workaround is setting shell to bash:
:set shell=/usr/bin/bash


--
Manfred


Charles E Campbell

unread,
Apr 5, 2020, 11:52:58 AM4/5/20
to vim...@googlegroups.com, Manfred Lotz
Try looking at :help netrw-debug .  The trace will tell you more about
what was actually done.

Regards,
Chip Campbell

Manfred Lotz

unread,
Apr 5, 2020, 2:39:23 PM4/5/20
to vim...@googlegroups.com
I tried but did not see any debug messages.

--
Manfred



Tom M

unread,
Apr 5, 2020, 10:40:01 PM4/5/20
to vim_use
A solution (or workaround?) to (the root cause of) this issue has been posted in this group a few weeks back in this discussion:
"netrw#BrowseX fails when invoked from gvim on Ubuntu"

The trick is to use:
:!xdg-open http://www.vim.org &

instead of:

Note the ampersand at the end of the first command. See the original discussion for more details.

I didn't look into the netrw plugin but I suppose there is a way to configure it so that the gx command launches xdg-open via a background job (the ampersand form).

Tom


Charles E Campbell

unread,
Apr 6, 2020, 12:29:21 PM4/6/20
to vim...@googlegroups.com, Manfred Lotz
Did you turn debugging on in netrw?  As in, vi netrw.vim, :DechoOn, :wq .

Another note posted here suggested putting an "&" at the end of the
xdg-open; however, there are two lines in netrw that use xdg-open and
both have a trailing '&'.  At least that is so with v170c.  If you don't
have v170c, you can get it from:
http://www.drchip.org/astronaut/vim/index.html#NETRW .

Regards,
Chip Campbell



Regards

Manfred Lotz

unread,
Apr 6, 2020, 2:36:23 PM4/6/20
to vim...@googlegroups.com
Didn't help. Same as before nothing happens when typing gx.

--
Manfred

Manfred Lotz

unread,
Apr 6, 2020, 2:48:26 PM4/6/20
to vim...@googlegroups.com
On Mon, 6 Apr 2020 12:27:58 -0400
I think I am not smart enough to get debugging on.

I ran

vim netrw.vba.gz
:so %
:q

vim Decho.vba.gz
:so %
:q

Both times there came a message about a duplicate tag "netrw-cd" in file
/home/manfred/.vim/doc/pi_netrw.txt


Then I started netrw.vimc, and typed
:DechoOn

Here I got error messages

Error detected while processing function DechoOn:
line 7:
this file<netrw.vimrc> does not contain any Decho/Dfunc/Dret commands
or function calls.

which is true as netrw.vimc only has

set nocp
so /home/manfred/.vim/plugin/netrwPlugin.vim

--
Manfred




Manfred Lotz

unread,
Apr 6, 2020, 3:27:33 PM4/6/20
to vim...@googlegroups.com
I forgot to mention that also when typing

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


nothing happened.

Tom M

unread,
Apr 6, 2020, 4:30:34 PM4/6/20
to vim...@googlegroups.com
> I forgot to mention that also when typing
>
> :!xdg-open http://www.vim.org &
>
>
> nothing happened.

Running "xdg-open http://www.vim.org &" in a terminal - outside of
Vim/gVim - does work? If not, what messages and what exit code does it
give?

Tom

Charles E Campbell

unread,
Apr 6, 2020, 10:51:16 PM4/6/20
to vim...@googlegroups.com, Manfred Lotz
Yes, that's why you should turn debugging on in netrw.vim, not something
else.  netrw.vim should be in your $HOME/.vim/autoload/netrw.vim directory.

vim netrw.vim
:DechoOn
:wq

Then try gx or whatever; you should get a trace.

The trace is time consuming; FYI: to turn debug tracing off:

vim netrw.vim
:DechoOff
:wq

Regards,
Chip Campbell

Manfred Lotz

unread,
Apr 7, 2020, 12:35:30 AM4/7/20
to vim...@googlegroups.com
On Mon, 6 Apr 2020 22:51:04 -0400
Yes, it is. The newest one from your website.

> vim netrw.vim
> :DechoOn
> :wq
>

Yep, works now.


> Then try gx or whatever; you should get a trace.
>
> The trace is time consuming; FYI: to turn debug tracing off:
>

Hm, my cursor is onto an url and I type gx.

There is a message at the bottom:
DEBUG: start up DECHOREMOTE server

and a separate gvim window opened.

Now pressing enter I get the debug info which is 99 lines.

I send it to you with a separate mail.


Thanks a lot for your patience.

--
Manfred

Manfred Lotz

unread,
Apr 7, 2020, 3:52:00 AM4/7/20
to vim...@googlegroups.com
On Mon, 6 Apr 2020 22:30:11 +0200
Tom M <7to...@gmail.com> wrote:

> > I forgot to mention that also when typing
> >
> > :!xdg-open http://www.vim.org &
> >

This doesn't work in gvim but works in vim without problems.

> >
> > nothing happened.
>
> Running "xdg-open http://www.vim.org &" in a terminal - outside of
> Vim/gVim - does work?

Yes. Works flawlessly.


--
Manfred


Manfred Lotz

unread,
Apr 7, 2020, 4:44:43 PM4/7/20
to vim...@googlegroups.com, Charles E Campbell
On Mon, 6 Apr 2020 21:27:24 +0200
Here
https://superuser.com/questions/386646/xdg-open-url-doesnt-open-the-website-in-my-default-browser

I found an idea to try:

!xdg-open http://www.vim.org; sleep 2

This works in gvim.

Please note that !xdg-open http://www.vim.org& doesn't.


So, I would say it is definitely not a netrw problem.


--
Manfred




Reply all
Reply to author
Forward
0 new messages