Profile

Should I use Vim full-time?

Published on Mar 22, 2020

I’ve spent the last couple of weeks diving head-first into the world of Vim. At times, I’ve felt like a complete badass, zipping my way around the terminal, editing large chunks of code with ease. Other times… well, not so much.

For those who can’t squeeze more than a couple of paragraphs into their brains (don’t worry, I think I fall into that category too), here’s my summary:

Vim is great, and I’m glad I’ve spent some time familiarizing myself with it. I no longer feel like Vim is always the backup option if no IDE is available. Vim is now my first choice for quick edits. However, for my daily workflow, Vim is not the best choice. Most of the time, I’m reading through code or browsing the web. These tasks, I feel, have been optimized for use with a mouse or trackpad. At the end of the day, switching context between the keyboard-focused Vim and the mouse-focused almost everything else makes sticking to an IDE the more sensible option in general.

Why use Vim

Vim is everywhere. Today’s cloud-centric, distributed ecosystem has Vim installed on most machines. I can almost guarantee that if you open up your terminal right now and try vim filename, you’ll find yourself stuck in a Vim editor. SSH/RSH into any virtual machine or Docker container you have running, and you’ll probably see the same thing.

It’s pretty darn powerful, too. Getting proficient with Vim’s command mode—messing around with the various motions, operations, and macros—can sometimes seem magical.

motions - movements around the text, such as w (word) operations - the actions, such as d (delete) macros - on-the-fly shortcuts to replay the last command (.) or a series of commands (q)

It’s ultra-customizable. Don’t like the way your Vim editor looks? Want better code completion? Want to add some new operations to your toolset? You have complete customization by editing a few lines in your vimrc file.

What I was hoping for

Going into this, I knew you couldn’t become a Vim wizard overnight. Two weeks of Vimming later, I know this now more than ever.

My main goal was to just test out the waters. I had no expectations, so anything I took out of this would be a win. I knew I would take a productivity hit initially, but hopefully, the few hours lost over two weeks would be worth it in the long run. Long story short: yes, it is absolutely worth it.

How I went about it

From the start, I decided I was going 100% all-in on Vim. If I was editing single files, I did it straight from the terminal. Otherwise, if I needed an IDE for switching files, IntelliSense, or auto-formatting, I made sure to download a Vim extension. For IntelliJ, I used IdeaVim, and for VS Code, I used Vim - Visual Studio Marketplace.

I started my Vim journey as most probably do—using vimtutor. It’s essentially a tutorial document explaining everything you need to know to get started. It’s built into most OSs, so there’s no need to download anything. Just run vimtutor in your terminal.

My next few days were spent Vimming everywhere I could. Where necessary, I would tweak my vimrc file until I was happy with the look and feel. I decided to keep the power extensions to a minimum, as I wanted to first get a feel for raw Vim.

In my spare time, I would watch some Vim talks, just to get a taste of what was possible in the long run. Watching some expert Vimmers always seemed to help when my Vim motivation was waning.

The Results

The Good

Learning new things is always rewarding. This is particularly true in our fast-moving industry. Worst-case scenario: I would sink a bit of time into learning Vim, then realize it’s not for me and change back to a full IDE. Best-case scenario: I’d have a new favorite editor that I can use anywhere. Either way, I would have expanded my toolbelt with a handy new tool. Not much of a price to pay for the potential gains.

Secondly, Vim macros have changed the way I think when modifying code. Macros allow you to record a series of modifications to a line and replay them on any number of lines above or below. Most of these macros can be replicated with multi-cursor, but there are definitely some cases where macros can achieve the same results with potentially less hassle. It’s interesting to see how having replayable operations changes the way you think when coding.

Getting more comfortable with Vim has also had one surprising side effect: I’m now more inclined to do general modifications directly from the terminal. Moving files, deleting folders, searching in folders for a specific file—previously, I’d rarely do this from the terminal, and often I’d need a quick Google refresher since I’d forget most of the commands minutes after using them. Now that I’m not as uncomfortable with editing files in Vim, I find myself managing files and folder structures from the terminal more often.

The Bad

In isolation, I can definitely see the argument that your average Vimmer will outperform your average IDEr. Even in my couple of weeks, I could see some speed improvements when digging into a single file and making changes to it. But here is where the problem lies: it’s surprisingly rare that I find myself editing only one file at a time.

Most of my time is spent flipping between multiple files, ctrl-clicking into function calls, cutting code out of one file, and pasting it into a new one. I feel this can be done much faster with an IDE. And with the trend of having smaller, singular, responsible code files, I don’t see this changing anytime soon.

Another potential pro of Vim is that it allows you to keep your hands on the keyboard full-time. In theory, this sounds fantastic. But again, what am I doing most of the time? I’d say a majority of my day is spent on my browser. I also constantly find myself scrolling through code, reviewing, or refactoring. These tasks have been designed and optimized for a scroll wheel (or trackpad) and cursor. Simply put, sticking to a mouse just makes sense for these tasks.

Summary

I won’t be sticking with Vim as my main editor. Am I disappointed? Maybe slightly. The idea of a super-customizable, powerful, lightweight editor I can use anywhere sounds great. But for my daily workflow, I find myself too reliant on an IDE with good refactoring tools. Global find and replace, or find all code references, are very important to me—an IDE just seems the better tool for this specific job.

But that doesn’t mean I’m not glad to have tried it out. Multiple times a day, I am making quick changes to a Kubernetes manifest or just updating a JSON key somewhere (local or on a cluster). This is where Vim shines. And at least now, I’m not spending five minutes clicking the down arrow to find the line I want to edit. I can undoubtedly say that having a basic grasp of Vim will come in handy for the rest of my career.

That was two weeks well spent.