www-gem words

vim-like web browsing: tridactyl

Published on

A discussion on Mastodon today reminded me about tridactyl . Because I use it all the time, every day, and it’s completely non-intrusive, this is a tool I easily forget while I’m lost when switching to another machine and instinctively try to use a keybinding in my web browser.

Tridactyl is an extension for firefox-based web browsers that allow the user to control the browser with the keyboard only. It replaces the default control mechanism with one modelled on vim. I’ve been a vim-like browser for decades with (the now defuncts) vimperator and pentadactyl. There are also similar options for chrome-based browsers. In a nutshell, the power of tridactyl comes from its extensibility which allow you to complete most common tasks you want your browser to perform with a single key press. Even better, you can customize any actions you can think of (including calling for external commands) to your own keybinding.

Note that Qutebrowser is a well-known browser that has a built-in vim-like browsing feature (as well as Nyxt which also offers emacs-like browsing) and claims to go beyond some plugins’ limitations because most of them are based on the WebKitGTK+ WebKit1 API, which causes a lot of crashes. I personally have never ever encountered any crashes with tridactyl and my browser of choice Librewolf is also more suited to my needs (especially in terms of security). Hence, despite 3 tries, I decided to not use Qutebrowser but I could not write a post about vim-like browsing without mentioning it and it may be a better choice for you, who knows.

╭── Why the need for a vim-like browsing experience?

From the github page “Like Vim, Tridactyl is modal, with the default mode being “normal mode”. In “normal mode”, many functions are available using keybindings. In “command mode” (when the command line is shown), you can execute more complex commands, known as “ex-commands”. All Tridactyl functionality can be accessed by ex-commands. You can bind any ex-command to a normal-mode shortcut. We also support a .tridactylrc file, of which there is an example in the root of this repository.”

This should already give you an idea of the power of this tool. You can explore everything by typing :help after having installed the extension but we’ll try to keep things simple here with some of the default keybindings:

Find mode

Bookmarks and quickmarks

Marks

Handling tabs

Extended hint mode

Binding custom commands

You can bind your own shortcuts in normal mode with the :bind command. For example :bind J tabprev to bind J to switch to the previous tab.
Simply type :help bind for details about this command.

You can also define your keybindings in .tridactylrc directly. The line for the previous example would be bind J tabprev

It’s a good time in this post to also mention the great autocompletion that comes with tridactyl when using the command line. Whenever you start typing something after typing :, you’ll be given with a list of autocompletion and once you have entered a command you can simply tap to see all the options available for this command. That’s how you make your users happy to tweak things :)

╭── Going beyond navigation

Customize the Graphical User Interface (GUI)

We use our web browser so much that we like to feel at home with it and this is usually done by theming the browser and rearranging the bars (url, search…).

In addition to everything that tridactyl offers you, it also comes with theming options and GUI customization like you’d do in chrome.css but via the simple command guiset followed by:

When simplicity is backed-up by simplicity

tridactyl could be an awesome tool by default and a magic one if you take time to learn and tweak the beast. It’s overall not that complicated and once done you will never have to redo it again because you can easily import/export settings stored in the external configuration tridactylrc file which you can also edit directly (which may be useful to create your bindings instead of using the :bind command nth times).

Using external programs

I currently have my blog control panel open in my browser but I’m writing this post in neovim (without the need for a (neo)vim plugin) and once done the text will be automatically pasted as a new post in my blog interface.
This function is integrated in tridactyl and called edit-in-Vim. Using the same function, with a single keybinding I can fill any online form or search box in (neo)vim. This is especially useful for forums for example where it’s faster to type your text with style in your own text editor.

This is possible thanks to the native messaging which enables an extension to exchange messages with a native application, installed on the user’s computer. The native messaging serves the extensions without additional accesses over the web.

I now have other tools to access online videos with my favorite video player (mpv) but if you’d like you can bind the built-in function mpvsafe to any key to open online videos in mpv while browsing the internet without having to call the mpv yourself or copy/paste the video url.

╭── I couldn’t resist…

… to share one of my preferred command: fillcmdline Don’t be scared if you’re not familiar with tridactyl and it sounds weird to you but I think you may like it as well if you fall in love with this extension.

This command will basically prepopulate the commandline with some text for you so you can complete it before executing the command. The text can be a defined string or some text picked from another command. Here are two examples of the way I use it:

List and select one of my open tabs:

bind T fillcmdline bufferall

With that, I can hit T and a list of open tabs will be listed in my command line in my browser. From here I can chose which one I want to switch to.

Launch a search in a new tab

bind t fillcmdline_notrail tabopen search_engine_url&q=

Explanations:


Thanks for your read. Hope it's been useful to you.


Interact with this post using Mastodon or

Comment on wwwgem's post

Copy and paste this URL into the search field of your favourite Fediverse app or the web interface of your Mastodon server.

✄ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈

More food for thoughts? Check other posts about: #System