Unlearning vim
Recently I have been practicing a kata using vim as my editor. Over the course of my programming life the cumulative hours I have spent in vim probably comes to a pretty high number. Prior to my apprenticeship the consecutive hours spent in vim over any period of time would be relatively low.
The impact of this became apparent as I tried to bring down the time it took me to complete the kata. Stepping back to think about where I was spending time I realised that simple navigation was a problem. A lot of my time was spent with my right hand fingers holding down the arrow keys to get the cursor where I wanted to go. As most vim guides will tell you, the arrow keys are not something you should be touching often.
Vim offers a whole world of other navigation options. A quick look at a cheatsheet gives you commands like w to jump forward to the start of a word or fx to jump to the next occurrence of character x. Combined with verbs like deletion (d) and numeric modifiers you can achieve a lot in a single command.
Get Phil Meier’s stories in your inbox
Join Medium for free to get updates from this writer.
As an example consider the following line
string[0..line_length] + "\n" + word_wrap(rest, line_length)Now imagine the cursor is at the start of the line and we want to delete everything up to the + word_wrap in order to replace it with a function call. Previously I would have been tempted to hold the right arrow to reach the point we want to delete from and then backspace to delete to the beginning. Maybe I would have thought further and pressed contrl-v before holding right so that a single d command would delete the whole selection.
How about just d2f" ? This single command deletes to the 2nd occurrence (f) of the ” character, achieving what we want much quicker. Change that d to a c and we will even be in insert mode after the command, ready to type in that new function call.
Remembering and considering commands like this is clearly easier said than done. Like learning a new language I am sure it will take some time to become second nature. Even worse I feel like my previous vim experience has already ingrained some bad habits that are difficult to break…
I guess it is back to the kata to continue unlearning vim!





