Adjusting Keyboard Shortcuts

23:17 Mon 27 Sep 2010
[, , , , ]

This post is about keyboard shortcuts, remappings, application switching, and a little bit of workflow, primarily in the context of OS X and Vim, so it might not be of interest to all readers.

My serious computer use started on Windows. I’ve ditched a lot of the keyboard habits from that OS, but one of them that remains is application switching. Windows this with Alt-Tab and Shift-Alt-Tab. Many free windowing systems are set up the same way, and when I used them I continued to rely heavily on those shortcuts. The basic modern application switcher operates as a stack: if I switch from Vim to Firefox, Alt-Tab will switch me back to Vim, and this quick alternation between two programs is my primary use case. If I switch from Vim to Firefox to Thunderbird, holding Alt and hitting Tab twice will bring me back to Vim. It gets more awkward with switching between more than about four programs, but I’m so used to it that it doesn’t tend to bother me.

When I started using OS X, I just switched using Cmd-Tab, which is the OS X convention. Note that on a Windows keyboard the Alt key is left (and right) of Space, and so it’s a fairly easy shift to get from the home keys to where the thumb holds Alt and the middle or ring finger hits Tab. On Mac keyboards, the Cmd key is left (and right) of Space, so that should be fine… except that I use an external keyboard designed for Windows. So its “Windows key” is actually Cmd, and it’s not as convenient for application switching (or anything else).

To get around this, I mapped CapsLock to Cmd. That works well, as now I hit CapsLock-Tab to switch, and that’s a really easy combination to hit. In addition, it works for all the other OS X Cmd-based shortcuts, most particularly Cmd-C and Cmd-V for copy and paste.

To add another wrinkle, I’ve become very used to the standard OS X usage of the Alt key to enable characters that aren’t on the basic keyboard, so for example I use Alt-_ to produce an em dash, and Alt-[ to produce left quotation marks.

This has all worked pretty well for me, but my increasing use of Vim (and various terminals) has made Ctrl a more important key. Ctrl is stuck out there on the very edge of the keyboard, and I’ve been making an effort to avoid the kind of awkward chording that is required by shortcuts requiring Ctrl. The typical geek response to this is to remap CapsLock to Ctrl… a switch that I’ve made very awkward for myself.

Vim has plenty of keybindings that make use of Ctrl, and I’ve been mostly avoiding them because of how awkward they are. I dislike it every time I need to hit Ctrl-W W to switch between windows, although I’m accustomed to Ctrl-Tab to invoke BufExplorer. In other words, I think that the awkwardness of the Ctrl key is holding back my Vim development. This means I need CapsLock back from Cmd.

My first thought was conditional keyboard switching, i.e. having CapsLock be Ctrl in Vim and Cmd everywhere else, but that appears to be difficult to implement, and also seems quite confusing in the very common case of switching between Vim and something else. So, Cmd really does have to relinquish the CapsLock spot.

Another thought is to simply switch Alt and the “Windows key” on this keyboard. It’s possible that should have been my very first course of action. I’ve been trying that during the writing of this blog post, and it might actually be a viable solution, although the em and en dashes and various quotation marks become trickier to chord out. What I would really like to do here, but which appears impossible with the basic OS tools, is leave the keys to the right of the keyboard as they were originally, but make the Alt key to the right of the keyboard function as Cmd, as that turns application switching and cutting and pasting into a two-hand operation that’s actually quite easy and doesn’t require uncomfortable chording. But that doesn’t seem possible without additional software.

If I need additional software, perhaps I should set up an entirely ideal situation, which I think would be making CapsLock map to Ctrl and then telling the OS to treat Ctrl-\ like Cmd-Tab. The \ key isn’t one I use in conjunction with modifier keys much, and so it seems like a safe key to sacrifice to this approach. It’s also ideal in that the chord required to combine those keys is two-handed and easy. It does leave the problem of cutting and pasting, however.

The additional software I’m considering is the awfully-named KR4MB, recommended by Seth. However, it’s not exactly any easy piece of software to configure, and I’m not spectacularly enthusiastic about editing XML and then recompiling KR4MB trying to get it to do what I want. For the moment, I think I have to try out the compromise solution of making this keyboard act like a standard Mac one and then adding the CapsLock as Ctrl mapping. I suspect this might confuse me over the next couple of days, but if it works then hopefully I can get somewhere with all the nice Vim goodies that are currently hiding under the Ctrl key.

3 Responses to “Adjusting Keyboard Shortcuts”

  1. Barak Says:

    You’re correct; my preferred solution (Windows keyboard on a Mac) is CapsLock == Ctrl and to swap Cmd and Alt. This has been the most consistent feel, and the real win is that, as the Mac intends, all the standard Mac shortcuts are chorded with the thumb.

  2. Seth Milliken Says:

    FWIW, kr4mb could easily make CapsLock Ctrl only in Vim and Cmd everywhere else. Well, easily once you get past that recompiling after editing XML hangup you have. :-)

  3. Seth Milliken Says:

    The latest version of kr4mb no longer requires recompiling to pick up configuration changes. Just edit the XML and refresh in the preference pane.

Leave a Reply