Colemak and vim: “But what about h/j/k/l?”

I have my phone set to alert me when anyone mentions Colemak on twitter. It’s a fun one to follow, you get new people trying out Colemak at least once a week, and i love to encourage people.

One thing i see a lot is programmers talking about vim, and asking what you do about the h/j/k/l keys. Do you remap them or relearn them?

There is at least one person who has made a colemak-vim remapping plugin (see this discussion in the Colemak forum), but i can’t imagine it working well. If you try to put h/j/k/l back where you’re used to them then you have to find new homes for n, e and i. (h actually stays in the same place) As you may well know, if you’re reading this, n is next search match, e is end of word, and i gets you to insert mode.

So if you move those keys, where would you put them? Almost every letter in vim has some sort of significance, and many of them are chosen for the action they stand for, which is part of the power of vim.

My answer is to relearn them. Maybe it’s easy for me because i was on Dvorak when i learned vim, so i was never attached to the position of h/j/k/l in the first place. Curiously enough, in Colemak h/j/k/l all end up on the same finger: the index finger of the right hand. Some people complain that j and k feel upside down, and they do at first, but then you realise that Apple is busy rewiring our brains with “natural scrolling” (which i think is just awesome, by the way) and before you know it, Colemak and vim feel perfectly wonderful together!

So my advice: print out one of these Colemak/vim cheat sheets and just get used to it!

vi / vim graphical cheat sheet - Colemak version

Look! i’ve even done a typematrix version for all you Colemak people who pair program and need a keyboard with a hard wired Colemak switch!

vi / vim graphical cheat sheet - Colemak TypeMatrix version

Of course, the other great thing to note about Colemak is one of its big advantages over Dvorak: that punctuation characters remain in their QWERTY positions. Which is very useful for vim users! :)

Advertisements

File under: notes to self

Note to self: Not everything has do be done as quickly as is humanly possible!

I tend to want to type as fast as i possibly can, all the time, and code as fast as my brain can do it. Learning Vim has been an excellent exercise in slowing down a bit, thinking of the best way to achieve the effect that i need, in as few keystrokes as possible. I am really loving Vim now. Been using it for about 3 weeks and have no intention of going back to TextMate now. The best thing was when i did some coding at home at the weekend and was just so happy to have the exact same coding environment to work with at home.

Another lesson in slowing down is when coding with someone else. I tend to find my brain goes much faster than i can form words to explain what’s going through my head. It can be a frustrating experience at times. But today i made the effort to slow down, take the time to ensure that my colleague was still following my train of thought, rather than rushing ahead at full speed. It actually was quite a calming thing to do, like an exercise in mindfulness.

I have mentally renamed the toilet as the prayer room. Turns out it’s a great place to say a quick prayer, assess how i’m feeling, recenter myself, pray for peace and mental inspiration, wish blessings upon my colleagues … I have been wanting to be more aware of God in my everyday life, and this is a great way to do it.

I’m feeling great at the moment – really happy! People say that God makes a positive difference in their lives. Whether a divine being is really at work in my personal daily activities, or whether it’s my enhanced state of mind that comes from focus and prayer, i don’t know and i don’t really care. I just know that it’s working out well for me at the moment! :)

On learning Vim

I’m sure Vim is going to be a wonderful thing for me to have learnt – a skill that will stay with me and benefit me for the rest of my life. It’s just getting there that’s so hard!

I started using Vim in earnest this week. On Monday i used Vim in the morning, and switched to TextMate when i got too frustrated. Tuesday was periodic switching between the two. TextMate when Vim got on my nerves, and back to Vim when i found myself missing Vim features. Yesterday and today i have been entirely on Vim.

Yesterday was great – i really felt i was getting somewhere, and gaining speed. It started to be less about me getting around Vim, and more about me doing my work. Today has been a bit more frustrating, as i know it is slowing me down significantly in the short-term, but i’m sure it will be worth it!

I keep finding myself smiling at Vim when i have elegantly told it to do something quite complex. It’s like “Wow, Vim, you’re so clever!” Selecting a block of text and duplicating it, going five words in and changing the text to the end of the quote marks: vapyP5wct" – said as “visual a paragraph, yank, Paste above, 5 words, change till quote marks.

It’s so cool to have Git integration right within Vim, and now that i’ve got the hang of the NERD Tree, and manipulating windows and buffers, i’m coming along a treat! I’ve discovered i have quite a strong perception of the layout of a project – without a project drawer i just couldn’t think what to do or where to find anything! I’ve also decided i really like side-by-side windows so that i can see code and spec at the same time. I’ll do a screenshot when i’m on my big computer.

The biggest problem in fact is not the super-amazing-cleverness of Vim and its plugins. I’m getting the hang of them pretty fast. The hardest thing is just learning the basic commands – like – moving around! I still get j and k mixed up, and it requires so much brain energy to remember whether i want to type a or i, o or capital O … even to remember to press <Esc> to come out of insert mode. Invariably i get it wrong and have to undo all the time. Either that or i’m undoing when i don’t want to, because i think u is for up. Fortuately i discovered on a Dvorak keyboard, k is underneath u so that sort of reminds me that k is up.

I just hope it is not my dyslexia making it hard to learn the basic movements. Most of Vim makes a lot of sense to me. I like that it uses mnemonics and mostly pressing one key at a time. I love how you can combine keystrokes in sequences to achieve really powerful effects. I hear that when you get really good at Vim you’re not even aware of exactly which keys you’re pressing. You just think about what you want to do, and your fingers do it automatically. I’m sure i can get to that level of proficiency … it’s just a case of being patient with myself whilst i’m still learning.

It was like this when i was learning Dvorak, but i’m glad i did, and my fingers do just type without my having to think about where the letters are. I type at around 80 words per minute, which is pretty nice, so i’m sure with the power of Vim, i could be truly awesome!

Loving the vimtutor

A couple of times recently i’ve found myself doing <ESC>:wq in the internet instead of pressing the submit button. I don’t use Vim very much at the moment – really only to make Git commits – but i’ve had enough of a taste that i feel it’s something i want to learn properly.

For a few months i’ve been searching for a text editor that i can use both on the Mac at work, and Linux on my netbook and PC at home. TextMate is a wonderful thing, but there is no decent Linux equivalent. A colleague and i started writing OpenMate – an open source cross platform equivalent to TextMate … but it’s hard! I enjoy gedit but failed to get gedit installed at work. I’ve tried NetBeans and jEdit but didn’t like them much, and they feel too big and clunky for a netbook.

After a little bit of reading about Vim i have become very excited. More excited that i’ve ever felt about a text editor before! I’ve realised that my conception of Vim has been wrong. I used to press i straight away to get into Insert mode, and stay there until i wanted to perform a command, in which case i’d press <ESC> followed by the command. Now i realise that a better way to use it is to be in ‘Normal’ mode most of the time, press i to enter Insert mode very briefly, and press <ESC> as soon as i’ve finished inserting.

This afternoon i discovered vimtutor and have been really enjoying it! You can run it on any Unix/Linux based system; just type vimtutor at the command line. It takes you through every command, at your own pace. It gives you samples of text to correct, using the commands you have just learnt. It’s actually quite fun and demonstrates the power of Vim very effectively!

At the moment i’m still muttering everything as i go, like “delete … 3 … words” as i very slowly type d3w and i’m exclaiming in delight at almost everything i learn – like – “Wow! That’s so clever!” I’m sure soon enough i’ll be able to use it effectively without making a lot of noise about it!

It is interesting learning it for Dvorak, but not too difficult. The up and down keys are in my left hand, and the left and right keys are in my right hand. They all actually fit rather neatly under my hands and feel intuitive even though they are not all in a line together. To be honest, i think i probably prefer it to the way it works under Qwerty.

Here is a helpful Vim cheatsheet laid out for Dvorak. Thanks, Mark Schoonover!
Here is an excellent article about the wonders of Vi/Vim.

It’s ridiculous how exciting this feels to me! Perhaps it’s the sense of moving up another level in the geek hierarchy! :D