sysid blog

vimania-uri

September 01, 2022 ☕️ 2 min read

Like to double-click links in order to “open” them? Here is the keyboard-based VIM version.

vimania-uri

Key Features

  1. Open arbitrary URIs in text files, html, docx, pptx, jpg, png, mp3, …
  2. Save URI seamless in bookmark manager twbm for seamless CLI management
  3. Handles almost any kind of URI
  4. Paste URLs with human-friendly description

Why?

One magic power of an OS UI is the capability of opening most URIs by just double-clicking them. As a CLI worker using the mouse does not cut it, unfortunately.

Markdown

Certainly I use Markdown a lot and after a few burns I settled with plasticboy’s plugin. It allows me to create new files by just adding a link [topic](topic) and then jump to it by typing ge while the cursor is on the link. This opens the markdwown file and I am ready to go. Very convenient, even no need for the .md-suffix in the link specification.

Hmmm, one has to leave the suffix out in order to work. Ok, just a little thing to remember, right? No problem.

URI Handling

I used vim’s builtin netrw to open files via the gx-mapping. Again, add a link [topic](file.ext) and netrw uses the OS’s native open command to handle the file link. This means it can handle URLs, file paths, Microsoft Office Documents, etc…

A true productivity booster which mimics the behavior of just double-clicking a file in a GUI file-manager. Only, this time one must not miss the the suffix in the filename.

There should be only ONE way to do things.

All in One

I am only aware of one plugin which tries to be feature complete: mdnav. Unfortunattely this project is not maintained any more, so I forked it and started to integrate it with a CLI bookmark manager.

How ?

Simple user interface

Position cursor anywhere on URI and just say go.

go (open URL, directories, files, ...)

Paste links with human-readable link description instead of machine URL text:
<leader>vl (paste link)

Optional: Bookmark Manager Integration

Save URI in bookmark manager: twbm.

goo (open and save to bookmark DB)

To remove an URI from the bookmark database the `dd` VIM command has been hooked into, so that whenever an URI gets `dd`-ed, it also gets deleted from the bookmark database.
dd (delete URI containing line from markdown and DB)

Summary

This plugin hanles all URI use-cases in VIM text files transparently as you would expect it from your OS UI. No need to memorize several key shortcuts or commands. An additional benefit is the bookmark manager integration, which allow to open your URIs from the command line. A true productivity booster.


always be building, by sysid.

© 2022