Vim for Hacker Information – Quentin Santos

tl;dr: I made ViHN to learn Hacker Information with out having to maneuver my arms away from the keyboard. It’s freely accessible on Firefox and Chrome.
That is about but one other Hacker Information extension. However different individuals with my obsession for killing the mouse would possibly take pleasure in it.
A lot of the content material of this text is simply an historical1 speaking concerning the good ol’ instances. However you possibly can soar on to the description of the extension.
btw, I exploit Vim
I do know that I’m not the one one who had a keyboard-zealot section.
When GNOME Shell occurred, I used to be compelled to go searching for a brand new window supervisor. I ended up putting in Ratpoison. Just like the extra well-known i3, Ratpoison is a tiling window.
That signifies that, as an alternative of floating home windows you often transfer round with the mouse, you break up the display in “tiles” nevertheless you want, and assign home windows to them. By default, the display is made from a single tile, so home windows are full-screen. Then, you would possibly break up it in two halves, to point out two home windows side-by-side (for example, a textual content editor and a Wikipedia web page). It may appear pointless since you can too do that with common (“stacking”) window supervisor, however the vital distinction is the workflow.
With an everyday window supervisor, positioning home windows can really feel considerably restricted. As a newbie, you would possibly use the mouse to rearrange some home windows in order that they show all the knowledge you want in a handy manner. However that takes a number of seconds. And folks like me don’t have seconds to waste — we might be utilizing it to learn memes on Reddit as an alternative.

So we be taught the keyboard shortcuts to rearrange the present window within the left/proper half of the display. Sadly, there are occasions once you want to present three home windows on the identical time. After which, it’s a must to return to utilizing the mouse. Are you able to think about the horror?
With a tiling window supervisor, we will use keyboard shortcuts to show what number of home windows in nevertheless manner we would like. Wish to show 81 totally different home windows in a 9×9 grid to make pixel artwork maximize your productiveness? In fact, simply a number of keystrokes.
The actual profit, nevertheless, is that nobody else will have the ability to use your pc. You’ll have switched to a different tiling window supervisor by the point they work out the earlier one.
Word: Nevertheless, Ratpoison is a misnomer: since you possibly can nonetheless use your mouse to open hyperlinks in Firefox as an alternative of Tab-Tab-Tab-Tab-Tab-Tab-Tab-Tab-Tab-Tab-Tab-Tab-Return like a standard particular person2. Due to Valve, you even should click on on terrorists, as an alternative of just spotting the “g” in the middle of random punctuation. Fortunately, you possibly can stay within the TTY, learn paperwork with fbi and watch movies with libcaca.

Since, I’ve strayed from the rightful path, and switched to xfce43. I even tried Visible Code for some time (with Vim key bindings, in fact), however I all the time come again to Vim.
Hacker Information
After I was youthful, and extra harmless, I used to kill time by searching for script kiddies hideouts with superior search key phrases resembling “hacker discussion board”. I might take pleasure in watching numerous individuals attempting to impress one another with technical nonsense.

In some unspecified time in the future, I stumbled upon Hacker Information, which is definitely not a hideout for script kiddies5. It’s really a spot to advertise great business ideas, talk about major security flaws underpinning infrastructure of geopolitical significance, and discover advanced technical topics. And not even half the content material is concerning the newest technological fad6.

Sadly, it makes use of that quirky system the place the dialogue is organized in bushes, and folks vote for probably the most attention-grabbing feedback. In older forums, you merely needed to learn the 3000-message-long thread to search out the few insightful remarks. And with 20 messages per web page, that may be barely 150 pages to learn!
These fancy vote-based boards will let you skip total side-discussions of tangentially associated ideas. It’s such a disgrace that you simply gained’t should be taught concerning the correct solution to restore drywall in an American home once you have been simply curious concerning the latest JavaScript framework.
In any case, the purpose is that studying a remark tree includes extra than simply scrolling achieved in a linear thread. As a substitute, you would possibly need to return as much as the mum or dad, skip to the subsequent sibling dialogue, disguise a sub-tree, upvote or reply to a particular remark.
And as mentioned above, I’m not going to do all that onerous work with a mouse pointer.
Procrastinating Extra Effectively
At first, I simply wrote myself some user script to make use of J, Ok, and different keys to navigate Hacker Information feedback, after having achieved one thing related for SlateStarCodex. That was largely adequate, however I used to be not as systematic with code versioning on the time, and the format didn’t significantly encourage it. So I ultimately misplaced that script.
This led me to Refined Hacker News, which is definitely fairly good. Sadly, some issues are damaged, and it could actually take some time to load. And since it’s unmaintained, I didn’t have any hope of with the ability to repair probably the most annoying concern (the extension typically not working in any respect).

So, I lastly made my own browser extension for Firefox and Chrome. It’s referred to as “ViHN”. “Vi” as a shorthand for Vim7, and “HN” for “Hacker Information”. Get it? I do know, it’s very delicate.
It’s primarily centered on keyboard-based navigation, ought to introduce no seen delay, and decrease surprises. In fact, it has many Vim-like key bindings to navigate feedback (not simply J and Ok). You may have a look at the README for the checklist, however I’ve additionally included it under to avoid wasting you a mouse click on in case you are not utilizing Vimium.
Additionally, I stole the thought from bakkot’s SlateStarComments to shortly discover new feedback. I by no means fairly favored the thought of attempting to recollect what feedback the person might need seen. That is simply confounded by reloading the web page by mistake, not having the time to learn all the things at that specific time, not utilizing the identical browser or pc, and so forth. As a substitute, ViHN reveals an inventory of feedback in reverse chronological order. You may undergo that checklist (in fact utilizing key bindings), and cease once you get to these you already learn.

Amongst different options, you possibly can quick-reply/edit/delete feedback, preview feedback when replying/enhancing, it highlights op.
A much less seen characteristic is that manages requests (votes, favourite, flag, persistent collapse) and unfold them in time to keep away from the drastic charge limiting of Hacker Information. If a request ends in a 503 error (non-standard “too many requests”), ViHN will retry it later. This materializes within the type of “…” as an alternative of “favourite”/“flag” in hyperlinks and spinning arrow for votes8.
However this could not be worthy of Hacker Information if this was not used as an event to bike-shed a specific JavaScript framework. The extension is written is Vanilla JS. This permits maximal efficiency with minimal overhead and 0 construct time.

Key bindings
This part is reproduced from the README, and likewise accessible within the extension by urgent ? to toggle assist.
Navigate Comments/Stories
Key | Effect |
---|---|
j | Next comment/story |
k | Previous comment/story |
J | Next sibling comment |
K | Previous sibling comment |
g | Go to first story/comment |
G | Go to last story, last root comment or “More” link |
H | Focus on story/comment at the top of the screen (high) |
M | Focus on story/comment in the middle of the screen |
L | Focus on story/comment at the bottom of the screen (low) |
n | Switch to Newest Items |
h | Parent comment/story (see [#follow-links](Follow Links)) |
p | Parent comment/story (see [#follow-links](Follow Links)) |
Note: You can also select an item by clicking in its bounding box.
Follow links
Key | Effect |
---|---|
o | Open story link/comment |
O | Open story link/comment in background |
c | Open comment thread |
C | Open comment thread in background |
b | Open both story link and comment thread |
B | Open both story link and comment thread in background |
h | Follow “context” link (go to comment thread, but focus on current comment) |
p | Follow “parent” link (go to parent’s page, and focus on parent comment/story) |
1 | Open 1st link in comment (maintain shift to open in background) |
… | … |
9 | Open 9th link in comment (maintain shift to open in background) |
0 | Open 10th link in comment (maintain shift to open in background) |
Note: When on the “XXX more comments” link, you can hit either of [lLcC]
to go to the next page of comments.
Note: The digits of the numeric keypad work as well to open links in comments. However, this can only open links in foreground.
Note: When using AZERTY, the key bindings to open links inside comments still work like in QWERTY. Hit the 1 key without shift (like typing &
) to open the 1st link in foreground. Hit the 1 key with shift (like typing 1
) to open the 1st link in background. Same for the other link numbers.
Actions
Key | Effect |
---|---|
m | Collapse/uncollapse comment tree |
u | Upvote story/comment, or cancel vote |
d | Downvote story/comment, or cancel vote |
f | Favorite/un-favorite story/comment of the current page |
F | Flag/unflag story/comment of the current page |
r | Comment on story, or reply to comment (with preview) |
e | Edit comment (with preview) |
D | Delete comment |
Ctrl+Return | Submit current form |
Navigate Newest Items
In the Newest Items list, the following key bindings are available:
Key | Effect |
---|---|
l | Show selected comment/story |
j | Next comment/story |
k | Previous comment/story |
J | Jump 10 down |
K | Jump 10 up |
g | Go to top story/comment |
G | Go to last story/comment |
n | Switch back from Newest Items |