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.

1

1 Answer 1

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>
7
  • 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
    Commented Jan 11, 2020 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. Commented Jan 11, 2020 at 15:44
  • Any explanation why you removed the <C-r>" and the yiW ? Commented Jan 11, 2020 at 15:50
  • it doesnt seem to be doing anything that I can see
    – D. Ben Knoble
    Commented Jan 11, 2020 at 16:13
  • 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? Commented Jan 7, 2022 at 17:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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