Keyboard-Centric Operation

tech choice keynav vim xmonad workflow

Back around the time that I was learning vim, my friend Simon from university introduced me to the concept of a "power user".

In general, a power user is someone that can get his or her way around a computer with great familiarity and ease. As someone who uses a computer very often - let's say... more than the average person - that part about "great familiarity and ease" appealed to me quite a bit. In order to get to that point, part of it requires getting used to certain workflows that seem weird at first, but are really efficient once you're more used to it. Part of it requires the right hardware and software. In the end, it mostly requires experimentation and practice.

Back to vim. vim is a text editing program. I use it mostly for writing code. It's a command-line program, meaning that it's completely text-based: no toolbars, no icons, no buttons. You can't even use the mouse with it. What really sets it apart, though, is the fact that it's a modal editor; meaning it has "modes". So when you open vim for the first time, you'll see that you can't immediately start typing your text. That's because by default, vim is in "command mode". Certain letters that you type are issuing commands to the editor. This could be as simple as deleting a character or a line, or switching to another mode. You need to switch to the "insert mode" before you can actually type your content. Incidentally, vim is also notoriously and hilariously difficult for beginners to exit.

Modes? No buttons? No mouse? Why go through all the hassle? Because, despite the steep learning curve, vim is really efficient to use. I can get far more done in the same amount of time in vim than I could using, for example, my previous default editor, notepad++. And one of the greatest parts of it is, I don't have to use the mouse.

Keyboard-Heavy Workflow

That's right. As it turns out, the mouse is a remarkably inefficient computer input device for many situations. Take as a sample use case: moving the cursor of a text editor. With a mouse, you would first have to take your hand off the keyboard, and lay it on the mouse. Next, you would usually have to move the mouse a bit in order to find the pointer on the screen. If you have a nice editor, the pointer was probably hidden so that it is out of the way. Once it has reappeared and you see it dancing in a corner, you need to scroll the page, so that you can find the place where you want the cursor. This is done either with the scroll wheel (it's rare to find a mouse without one), or by clicking and dragging the scroll bar. The first option requires several repetitive motions of your finger on the wheel. The second option requires locating the scroll bar, moving the pointer there, and moving it up or down while you hold down the mouse button. Then you need to locate the target text, and line up the little I-bar-shaped pointer with the space between the two letters where you want to be, before finally clicking to indicate that you want the cursor moved. Then you have to move your hand back to the keyboard, and line up your four main fingers with the four main keys of the home row. With vim, a similar operation could take a tenth of the time.

"So what?", you may say, "that only saved a few seconds!" Remember, however, that we are in "power user" territory. When you're editing text (especially code), most of what you do can be these kinds of operations. Saving potentially 90% of your time for each one adds up quickly.

I got the hang of it after some practice, and I've been hooked ever since. I've incorporated vim-style keyboard navigation into my web browsers with plugins (I use one called cVim, but I've also used others like vimium, and vimperator). With this, you can move within and between pages almost completely without a mouse. Among other controls, the j and k keys let you move down and up (respectively), and when you want to 'click' on a link, you hit f. A two or three letter code appears next to each link that's currently visible, and you type the code of the one you want. It sounds tricky, but you get used to it quickly, and once you do, it's so much faster than the mouse.

Last example for now: my window manager. As I've mentioned before, I use a program called xmonad as my window manager. This lets you arrange all the windows on the screen and switch between windows using the keyboard. I'll write about it more in depth sometime, but here's the gist of it. xmonad is a tiling window manager, which means that all the windows on the screen fill up every square millimeter of the monitor. Unlike in traditional systems, a window is not a free-floating box that can be dragged around or resized. It can't be minimized. You select a layout which determines the size of the "main" window on screen and those of all the other open windows. This system takes a little more mental adjustment than the others, but it's just as awesome.

None of this is to say that a mouse isn't useful or awesome! Without the mouse, computers would probably still be the playthings of engineers, scientists, and nerds like me. And there are times when a keyboard simply doesn't cut it. A great example is when you're looking at a folder on your computer with a lot of images, and you want to select some for copying or editing. Chances are, the photos came from a camera, and have a consistent, numeric naming scheme. There's no way that I'm going to type out the names of all the images I want - I'll just point and click. One hand on the mouse, one hand on the ctrl or shift key. Also, if I have a touchscreen, sometimes just reaching out and tapping something makes more sense. I also like it when I'm using a laptop, and I can use the trackpad below the center of the keyboard without hardly moving my hand.

No Mouse At All?

All that said, what if you wanted to get rid of the mouse altogether? I'm not saying that I or anyone else would want that, but there may nevertheless be short instances where it might be better, or where you have no choice. There was a time at work when the wireless mouse I had ran out of battery, (Why is wireless so popular, I have no idea! How often do you use a computer sitting on the other side of the room? It can't be worth the hassle of managing batteries.) and so I spent an afternoon without any hardware pointing device. I got by, mostly because I don't need the mouse in large part (as just mentioned), and also because of these two programs.

Mouse Keys

The first is a function called "Mouse Keys". This is built-in to Windows and linux as an accessibility feature. It lets you move the mouse pointer with the numpad on the keyboard. The 8 key moves the pointer up, the 2 down, and the other keys in their respective directions (including diagonals). The 5 key clicks the mouse button. The arithmetic operator keys (+, -, /, etc) switch the mode of the mouse button for right-click, double-click, etc. There is nothing you can do with a regular mouse that you can't do with Mouse Keys (except maybe the scroll wheel functionality). It can be frustratingly difficult to calibrate speed and acceleration, but hey, you probably won't use it for long anyway.

keynav

The other one is a program called keynav. keynav is a regular package in Ubuntu, and can be installed with a single apt command. It takes a completely different approach than Mouse Keys. Rather than simulating the movement of the mouse pointer with directional keys, keynav lets you designate where you want the pointer to jump (or "warp") by subdividing the screen with grid lines until the focus area is targeting the spot where you want to click. Here's an example:

Suppose we're on a website and we want to click on that search bar in the upper-right corner.

First, we activate keynav. keynav is a daemon running in the background, and a special key sequence - ctrl + ; by default - will trigger it to start. A box that fills the screen will appear. The box has a vertical line and a horizontal line, which divide the screen into four.

The point where the two lines meet is where the action (such as the click) will happen if we choose to end the action now. But we don't want to click in the center of the screen, we want to go to the right, and up. keynav uses the h, j, k, and l keys to move left, down, up, or right (respectively) - incidentally, just like in vim. So I hit the l key to move to the right.

The selector is then cut in half, focusing on the right half of the screen. The lines help us figure out where the target will be next. Our search bar is still up and to the right, so I'll go right again.

And then k, for up.

Now the crosshairs are within our target area. If the target area was smaller (only a few pixels across), we may have to keep sub-dividing until it lines up, but in this case, we're done! To click, I press enter or the spacebar. The keynav grid lines disappear, and the pointer clicks on the search bar.

There are other functionalities, such as right-click, middle-click, simply moving the pointer, moving the selector, undoing a subdivision (if you make a mistake), and others. It's also fully customizable - all settings are in the keynavrc file in the home directory. I added key bindings so that the selector can move diagonally (up and to the right, etc), among a few others.

It does have a few quirks. Dragging is a little awkward (though it is a clever solution), and it doesn't always work between multiple monitors. And, as with Mouse Keys, there's no scroll wheel. Overall, though, keynav is pretty cool. It has a surprisingly short learning curve. I got used to it after a few minutes of trying it out. It's also kind of fun... as fun as a pointing program can be, anyway.

Conclusion

All habits aimed at efficiency take constant minor adjustments. Me, I find it fun to discover new ways of doing little things, and crafting my techniques. Since my computer is my work environment, my hobby area, and my entertainment center, I think it's worth a little effort to perfect.

Add a comment

Previous Post Next Post