I have gx which works with opening files. However, when I try and open a url, it always tries using wget:

[No write since last change]
dyld: Library not loaded: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib
  Referenced from: /usr/local/bin/wget
  Reason: image not found

Command terminated

I am hoping that opening a url is as simple as it is on my terminal, just typing $ open <url> and it opens in my default browser. I've tried setting:

let g:netrw_browsex_viewer= "open"

But it seems like that command isn't working or doing anything because the same thing happens, even if I enter in garbage such as:

let g:netrw_browsex_viewer= "asdfasdfasdf"

What is the setting to make it just do an "open" when I get a url under my cursor and press gx ?


2 Answers 2


Quick solution (actually just a workaround)

On Linux, add the following to your .vimrc to override netrw's mapping and produce the desired behaviour:

nmap gx :silent execute "!xdg-open " . shellescape("<cWORD>")<CR>

You can replace xdg-open with your preferred browser. But in this case, if your browser is not already open, then you may need to background the process when it starts up:

nmap gx :silent execute "!google-chrome " . shellescape("<cWORD>") . " &"<CR>

If you want to select the link in Visual mode first, then you'll need a visual mapping:

vmap gx <Esc>:silent execute "!google-chrome " . shellescape("<C-r>*") . " &"<CR>

(Escape leaves visual selection mode, and <C-R>* pastes the * register, which contains the latest selection.)

On Windows, one of the following might work (untested):

nmap gx :silent execute "!chrome " . shellescape("<cWORD>")<CR>
nmap gx :silent execute "!firefox " . shellescape("<cWORD>")<CR>
nmap gx :silent execute "!start microsoft-edge:" . shellescape("<cWORD>")<CR>

While you are debugging this setup, you'll want to use :execute instead of :silent execute

Problem details

The details of my situation, in case someone can help to debug.

I am getting this behaviour (similar to the OP, but with no libssl error):

  • gx immediately calls wget to download the HTML page into a /tmp/____ folder,
  • After wget has finished, then a browser opens up, pointing to the downloaded file.
  • I see the HTML displayed in the browser, not the rendered page as I had hoped for!

I'm running KDE5 on Manjaro with this version of Vim:

:verb nmap gx
n  gx            <Plug>NetrwBrowseX                                                                                                    
        Last set from /usr/share/vim/vim82/plugin/netrwPlugin.vim line 82

VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Sep 17 2020 21:54:53)
Included patches: 1-1704
Compiled by Arch Linux
Huge version with GTK3 GUI.  Features included (+) or not (-):
+acl               -farsi             +mouse_sgr         +tag_binary
+arabic            +file_in_path      -mouse_sysmouse    -tag_old_static
+autocmd           +find_in_path      +mouse_urxvt       -tag_any_white
+autochdir         +float             +mouse_xterm       +tcl/dyn
-autoservername    +folding           +multi_byte        +termguicolors
+balloon_eval      -footer            +multi_lang        +terminal
+balloon_eval_term +fork()            -mzscheme          +terminfo
+browse            +gettext           +netbeans_intg     +termresponse
++builtin_terms    -hangul_input      +num64             +textobjects
+byte_offset       +iconv             +packages          +textprop
+channel           +insert_expand     +path_extra        +timers
+cindent           +ipv6              +perl/dyn          +title
+clientserver      +job               +persistent_undo   +toolbar
+clipboard         +jumplist          +popupwin          +user_commands
+cmdline_compl     +keymap            +postscript        +vartabs
+cmdline_hist      +lambda            +printer           +vertsplit
+cmdline_info      +langmap           +profile           +virtualedit
+comments          +libcall           +python/dyn        +visual
+conceal           +linebreak         +python3/dyn       +visualextra
+cryptv            +lispindent        +quickfix          +viminfo
+cscope            +listcmds          +reltime           +vreplace
+cursorbind        +localmap          +rightleft         +wildignore
+cursorshape       +lua/dyn           +ruby/dyn          +wildmenu
+dialog_con_gui    +menu              +scrollbind        +windows
+diff              +mksession         +signs             +writebackup
+digraphs          +modify_fname      +smartindent       +X11
+dnd               +mouse             +sound             -xfontset
-ebcdic            +mouseshape        +spell             +xim
+emacs_tags        +mouse_dec         +startuptime       -xpm
+eval              +mouse_gpm         +statusline        +xsmp_interact
+ex_extra          -mouse_jsbterm     -sun_workshop      +xterm_clipboard
+extra_search      +mouse_netterm     +syntax            -xterm_save
   system vimrc file: "/etc/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
  system gvimrc file: "/etc/gvimrc"
    user gvimrc file: "$HOME/.gvimrc"
2nd user gvimrc file: "~/.vim/gvimrc"
       defaults file: "$VIMRUNTIME/defaults.vim"
    system menu file: "$VIMRUNTIME/menu.vim"
  fall-back for $VIM: "/usr/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_GTK  -I/usr/include/g
tk-3.0 -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/incl
ude -I/usr/include/harfbuzz -I/usr/include/freetype2 -I/usr/include/libpng16 -I/
usr/include/libmount -I/usr/include/blkid -I/usr/include/fribidi -I/usr/include/
cairo -I/usr/include/pixman-1 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/gio-u
nix-2.0 -I/usr/include/atk-1.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/dbu
s-1.0 -I/usr/lib/dbus-1.0/include -I/usr/include/at-spi-2.0 -pthread    -march=x
86-64 -mtune=generic -O2 -pipe -fno-plt -D_REENTRANT  -U_FORTIFY_SOURCE -D_FORTI
Linking: gcc   -L. -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -fstack-pro
tector-strong -rdynamic -Wl,-export-dynamic -Wl,-E -Wl,-rpath,/usr/lib/perl5/5.3
2/core_perl/CORE  -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -L/usr/local
/lib -Wl,--as-needed -o vim   -lgtk-3 -lgdk-3 -lz -lpangocairo-1.0 -lpango-1.0 -
lharfbuzz -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject
-2.0 -lglib-2.0  -lSM -lICE -lXt -lX11 -lXdmcp -lSM -lICE  -lm -ltinfo -lelf
-lcanberra  -lacl -lattr -lgpm -ldl   -Wl,-E -Wl,-rpath,/usr/lib/perl5/5.32/core
_perl/CORE -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -fstack-protector-s
trong -L/usr/local/lib  -L/usr/lib/perl5/5.32/core_perl/CORE -lperl -lpthread -l
dl -lm -lcrypt -lutil -lc   -L/usr/lib -ltclstub8.6 -ldl -lz -lpthread -lm
  • your workaround works fine, but did you find any fix for this issue?
    – Monu
    Jan 22, 2021 at 8:49
  • I still have the bug if I do a visual select first before gx.
    – khatchad
    Aug 9, 2021 at 15:09
  • 1
    @RaffiKhatchadourian For that you'll need a vmap. I have added one to the answer. Aug 12, 2021 at 8:26
  • 1
    It's not strictly true that "* contains the last visual selection: see :help quotestar. The range * does stand for '<,'>.
    – D. Ben Knoble
    Aug 12, 2021 at 14:02
  • The * register is working for me on Linux. But if it doesn't work on Windows, we can do a yank instead of that Escape. (Of course if we yank, it will clobber a register.) (Thanks Ben for the heads up. The docs still confuse me!) Aug 17, 2021 at 8:37

FWIW, this issue is still open on github, but there are now at least a couple plugins that should restore this functionality:


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.