Sean's i/o Stream

Musings-as-a-Service

Giving my mouse a break

  • April 13, 2015
  •   category: productivity
  • tags: typing, efficiency, keyboard, os-x

Been doing more and more work on the command line as my Mac becomes more and more of a pretty Linux terminal and I think it is time I start focusing on improving my effecientcy without the mouse. I have been passible with vim and added screen to my workflow a few years back which was a huge help. Now I have been looking more at tmux and improving my proficiency with vim to a competent level. I’m not giving up my Code Editors or Eclipse just yet but just want to save myself some time and effort in my day to day work.


Remap CapsLock key to something useful (aka Control)

Lots of posts about this one, I like the tagline on thegarvin.com post “Add 10 years to the life of your left hand”1. So I rebound my CAPLOCKS <-> Control key for my little Apple keyboard, plus some diy labeling thanks to my wife’s label maker! I know it’s hard to tell from the pro-mod below, but that is not where the actual Control and CapsLock keys are by default…

Apple Keyboard labeled

One habit I can see that I need to work on first is the use of the arrow keys as my first choice… I know like the great Bobby Brown once said, “it’s my perogative!” but I think this one is really slowing me down having to move my hands all the time. So I looked for a few other quick ways to work on that.


Karabiner

Install Karabiner to bind h-j-k-l with Ctrl modifier to new arrows, they have an existing option to turn on the hjkl arrows when not editing text, but I think having it enabled for with and without the modifier would confuse me, but here is a simple private.xml for adding this.

<?xml version="1.0"?>
  <root>
    <item>
        <name>Arrow keys in Home Row</name>
        <appendix>Add Control+h to Left"</appendix>
        <appendix>Add Control+j to Up"</appendix>
        <appendix>Add Control+k to Down"</appendix>
        <appendix>Add Control+l to Right"</appendix>
        <identifier>private.arrow_keys_at_home</identifier>
        <autogen>__KeyToKey__ KeyCode::H, VK_CONTROL, KeyCode::CURSOR_LEFT</autogen>
        <autogen>__KeyToKey__ KeyCode::J, VK_CONTROL, KeyCode::CURSOR_UP</autogen>
        <autogen>__KeyToKey__ KeyCode::K, VK_CONTROL, KeyCode::CURSOR_DOWN</autogen>
        <autogen>__KeyToKey__ KeyCode::L, VK_CONTROL, KeyCode::CURSOR_RIGHT</autogen>
    </item>
</root>

I first tried remapping the keys in Terminal preferences to nothing, but I quickly realized I out-smarted myself and that this defeated my new mappings from Karabiner as well… alas the arrow keys are still alive, but you can be rest assured that I will get a Chippy Slap!2 everytime I use them.


Disable arrow keys in Vim

Another useful trick to force some better habits3 is to disable the arrow keys in yoru .vimrc file. I installed the HardMode4 plugin and have been playing with that to see how hard it is, for me moving from the arrow keys already I am pretty much just getting used to using the arrow keys at hjkl so removing those seems a bit of a stretch. I can see how the word movement will help but couldn’t get used to moving vertically with only the (){} commands help as these are still a bit clunky for me to reach easily. I’m not uninstalling that plugin as I think it has merit, but I need to ease into it or re-purpose the hjkl keys to (){} keys to kick it up a notch.

For now I’ll keep it is EasyMode and be a weakling, but a weakling without functional arrow keys though, I added the Contra5 code straight to my .vimrc for the extra lifes:

map <up> <nop>
imap <up> <nop>
map <down> <nop>
imap <down> <nop>
map <left> <nop>
map <right> <nop>
imap <left> <nop>
imap <right> <nop>
" B-A-start

" Disable Visual mode too
vmap <up> <nop>
vmap <down> <nop>
vmap <left> <nop>
vmap <right> <nop>

With the arrow keys disabled I’m now forced to use the other shortcuts and hjkl for getting around, so far so good with the movement. Then I found this6 helpful post on vim movement, so I can clearly see there is more to learn here and I will focus more on this.


tmux

I mentioned that I have been using screen for a few years now, and it seems to have reached a point where it is installed by default on Ubuntu and easy to install on most any system, but it is not ideal. Starting reading tmux: Productive Mouse Free Development and it inspired me to try tmux instead.

I like having quick cheatsheets to help out, could not find one that was what I was looking for so I put one together on mindmup.com and hosted it at sgwilbur/mindmup-cheatsheets if you have a hankering to try it out.

tmux commands mindmup

Work in progress and I will note that this includes some custom bindings for resizing at the moment, which I am not sure I will keep but this is s a helpful one-pager I have above my laptop on the wall for now :)


Reference:
Footnotes:
Back to Top