VIM: Open a File In a Web Browser on Linux

07/13/20191 Min Read — In DevTools, Vim

Today I learned two neat tricks:

Put your cursor on a link (in normal mode), and type gx.
This will open the URL in a browser window.

What if you want to open a file in a web browser?

On Linux, you can type :!xdg-open % to open the current file in the default browser.

(On a Mac, just type :!open %)

If you want to make sure that your file is saved, you can first update the file and then pipe it through xdg-open:

:up | !xdg-open %

Further Reading