Adapting Vim to Alternative Keyboard Layouts

by Noah Frederick |
Photograph of an ortholinear keyboard with Latin and hiragana legends on the key caps, Colemak layout
Technik keyboard with frosted acrylic case, Choc Robin switches, and MBK Legends key caps

You learned Vim/Neovim on a standard QWERTY keyboard layout and are considering switching to an alternative layout like Colemak or Dvorak: How do you reconcile your established muscle memory with this new typing paradigm? Or, maybe you already use an alternative keyboard layout and are just getting into Vim. Do you remap some or all of the keys to their original QWERTY positions, or leave them wherever they fall on the keyboard?

Remap or Retrain?

If you’ve already learned Vim on QWERTY it may be tempting to try to preserve your existing muscle memory by remapping a bunch of keys to their original QWERTY placements (perhaps using the langmap feature). While this may help with the transition in the short term, it creates a major incompatibility between your personal setup and Vim’s stock configuration. Remapping doesn’t ultimately make much sense, since almost all normal-mode commands are assigned to keys mnemonically, not based on their physical positions.

What About hjkl?

The iconic home-row h, j, k, and l directional movement keys are often at the center of Colemak keyboard converts’ consternation. In reality, linewise—and especially characterwise—cursor movement is not central to Vim’s editing model. These motion commands are complemented by a host of alternative commands, including those based on word boundaries (e.g., w, b), columns (e.g., 0, $), and search targets (e.g., f, /), meaning that simple characterwise motions are rarely needed and are rarely the best option in a given scenario.

With that assessment in mind, their placement on the keyboard’s home row is of diminished importance. Here are a few suggestions for handling directional navigation keys in an alternative layout:

  1. Use hjkl in their new placements: Their placement is still fairly intuitive in Colemak, as long as you reconceptualize linewise movement like you’re pitching up and down with a joystick.

  2. Just use the arrow keys: That’s what they’re there for, after all.

  3. Use a navigation layer: My QMK-based keyboard firmware provides a separate navigation layer that is activated by holding a thumb key. The layer provides HomePgUpPgDnEnd and on the home row. This is the compromise I prefer, since my keyboard doesn’t have dedicated directional keys, and it works the same across any software, rather than being Vim-specific.

Further Reading