Software Engineerium

Matt Steward

Matt Steward

Va Va VIM!

Way back in the distant past, no, further back than that, my working days were spent hammering away in the mysterious and arcane editor vi . In my memory, hazy though it is, these were my most productive coding days, I just seemed to crank out so much stuff. There is a caveat to this, my roles in the early days were 100% coding focused, and there were no distractions, literally, none. Well, ok, you could get up and make a cup of tea (even coffee hadn’t been invented yet). But there were no agile ceremonies, no interweb to browse, no new technologies to learn (technology was a strictly enforced monoculture in each company or team). But there is no doubt vi contributed to my productivity.

Recently, as a result of having some time on my hands (furlough) and some stiffness in my shoulder (mouse induced RSI) I decided to revisit my old friend vi. For those totally unfamiliar with vi, the RSI aspect is relevant because vi was designed with no dependency on a mouse, there weren’t any.

Things I learned…

  • vi is now called vim, or rather vi is now superseded by an entirely separate tool called vim, which stands for vi improved.
  • Muscle memory is long lasting. Indeed I have been religiously hitting <esc> after typing code my entire career, much to the confusion of every version of Visual Studio, IntelliJ, Eclipse etc that I’ve used over the years.
  • Muscle memory takes a while to acquire. I have spent a LOT of time Googling for how do I do x in vim. You can do everything in vim without leaving the safety of your keyboard, but you won’t remember it all, muscle or not, for a while.
  • There is an excellent vim extension for VS Code .
  • VS Code and vim work really well together, for example there is good integration with multi-cursors which is a real time-saver.
  • There is an outstanding tutorial written by Jaime González García that walks through installing and using vim in VS Code.
  • My shoulder is much better.

Things I recommend…

  • Watch a vim overview/tutorial. You won’t (and don’t need to) remember all the commands, but it helps to have a high level overview of the modes and the type of things vim is capable of.
  • Spend some time in vim, grab a code file that you have no emotional attachment to and just start hacking. Try to replicate the common actions of coding in that language using vim commands. There is a steep initial learning curve, so be patient and give this a little bit of time.
  • If you decide that you’d like to explore vim further:
    • Install a vim extension in your IDE of choice. This gives you the speed and precision of vim, with the benefits of the IDE, ie auto-complete, intellisense, snippets et al. If you really don’t get on with it, uninstall it again. Nothing lost.
    • Build your own cheat sheet, you can focus it on the commands you use most often, and building it will help to acquire muscle memory.
    • Put your mouse on eBay.