5

My issue happens with the key combination gx in normal mode.

The problems happens in Vim, (I have also tried in NeoVim and it correctly opens the link in firefox directly).

I have a test file /tmp/go-to-stackoverflow.markdown which contains the url http://www.stackoverflow.com

When I hit gx while the cursor is on the link:

  • it opens a new buffer window at the bottom which contains only one line with the link written in it
  • it displays during a few milliseconds (I had to redo it several times to get each words) the message netrw --No Line In Buffer--

Any idea what might be wrong in my configuration, how to fix the issue?

I use vim 8.1 on NixOs 19.09.

Stephane Rolland
  • 1,857
  • 2
  • 13
  • 23

1 Answers1

4

As pointed in the comments, it is a current bug that is still open. There is a workaround:

Add in the vimrc configuration file:

nnoremap gx :!xdg-open <cWORD> &<CR><CR>

(The original github discussion was referencing to this one below, but comments made it possible an improved version.)

nmap gx yiW:!xdg-open <cWORD><CR> <C-r>" & <CR><CR>
Stephane Rolland
  • 1,857
  • 2
  • 13
  • 23
  • 1
    Im shocked if this mapping works: I would it expect it to yank the WORD, then run xdg-open <cWORD>, then in normal mode type <C-r>" & <CR><CR>, and with nmap, those spaces could trigger leader mappings for me. The last half of it makes absolutely no sense. I would have written nnoremap gx :!xdg-open <cWORD> &<CR><CR> – D. Ben Knoble Jan 11 '20 at 15:13
  • I'm currently using it successfuly though and my leader key is space too. I'm gonna test your solution. I'll update the answer accordinly. – Stephane Rolland Jan 11 '20 at 15:44
  • Any explanation why you removed the <C-r>" and the yiW ? – Stephane Rolland Jan 11 '20 at 15:50
  • it doesnt seem to be doing anything that I can see – D. Ben Knoble Jan 11 '20 at 16:13
  • @D.BenKnoble I have edited the answer with your solution. – Stephane Rolland Jan 11 '20 at 16:25
  • 1
    In case anyone else is having trouble with gvim and this mapping: nmap gx :!xdg-open <cWORD> &<CR><CR>: My gvim wasn't opening anything with this but it worked fine in a terminal vim. It was driving me nuts. The problem turns out to be the guioption ! (run external commands in a full terminal window instead of dumb terminal). I turned it off: set go-=!. Lo and behold gx in gvim started opening urls in my external web browser again. So I guess something is broken with running external commands in a terminal window? – Lee Bigelow Jan 07 '22 at 17:57
  • @LeeBigelow I turned your separate answer into a comment, since it's directly related to an issue you had with the answer in here. Thanks! – filbranden Jan 07 '22 at 18:15