Why you should learn vi

By Greg Turnquist

Greg L. Turnquist worked on the Spring team for over thirteen years and is a senior staff technical content engineer at Cockroach Labs. He was the lead for Spring Data JPA and Spring Web Services. He wrote Packt's best-selling title, Learning Spring Boot 2.0 2nd Edition, and its 3rd Edition follow-up along many others.

March 8, 2012

I periodically run into new developers. It’s a wonderful opportunity to see what other people are doing  and what areas they work in. It always amazes me at how limited my own work and pursuits are in the grand scheme of things. I feel like I diversified myself at my old company by working on many different projects for different customers. In my current position, it seems like I get handed many tasks that aren’t closely tied together. But when I speak to others, it seems like there is an even wider range of things that are out there! Software really is amazing.

Inevitably, we want to know what tools we each use, what platforms we develop on, and the love/hate people have for Microsoft/Apple/Google comes out as well. I have never seen things go as viscous as things do in political discussions, but there are strong opinions everywhere in the arena of software and our tools. Of course, I always end up mentioning I use vi. A lot. Usually at least one, if not half of the people I speak to use it as well. Guess what? The other half use a GUI editor. Might I add, that they sniff that their GUI editor is more befitting our modern era. Heck, back in grad school, that was MY thinking. Someone mentioned they used vi, and I thought they were whacko. As succinctly stated, vi was created for terminal editors and predates the window-based revolution. (BTW, sometimes I find one person that uses emacs. I’m just saying.)

Of course, they’re right. vi DOES predate the era of windows. I don’t know why this implies pre-windows was somehow the dark ages, but that is the sense that I get. In this moment, if I’m feeling more confident in my choice of vi than my other colleagues, I put a foot forward and explain why. It’s the only editor that is always available no matter how I access a remote, non-windows server. That is it. Login in to a terminal server and then ssh to your box, and all you have is a shell. Trying to open a GUI texteditor requires:

  • You must use ssh correctly, so that it forwards X port requests to your local box. No extra arguments, and this doesn’t work. Oh, you used a terminal server? Sorry. Do not pass Go, do not collect $200.
  • You must have a local X server running.If it’s windows, that means buying some commercial software and having it open correctly (or already be open).
  • Your remote server must have this editor already installed. You want a specialized editor just like your development environment? You may have to go install it everywhere. What if you your development machine and target server are two different operating systems?
So, that is my argument in favor of vi. Having used it to manage lots of machines during my career, it’s commands are ingrained in my fingers, and I can use it effectively. Therefore when I’m on my development machine, I use it there to for some types of editing.
But what if I need to do some really intense editing of Java of Maven configuration files? Or other XML stuff? That is when I turn to my IDE. The reason it’s valuable to me is that is more than an editor. If provides shorts to API calls, automated running of unit tests with a set of keystrokes, and built-in refactorings. If I was dependent upon it just for editing, I would drop my IDE in a heartbeat.
Amidst all this discussion about why I use vi, and why you should too, let me answer the title of this post with something completely different. Why should you should learn vi? Because just about any tool out there knows the basic vi commands as well.
  • Visit Gmail? You can use “j” and “k” (i.e. down and up) to navigate through your list of email messages without moving to the mouse. 
  • What about Google Reader? Same thing. 
  • “But I don’t use Google! They are evil.” It doesn’t stop there. Checkout Twitter. You can hop from tweet to tweet using the same thing.

Next time you visit a web app, checkout if it responds to vi commands. You might be surprised. Perhaps this sounds like a self-fulfilling prophecy or old technology holding on for too long, but there is something to be said for efficient patterns that are still heavily used more than 40 years after invented.


  1. David Rawk

    Just for giggles I opened gmail, and opened up an email. Pressed hjkl.. Nothing happened. None of the keys moved me to the next email.
    Not convinced, but I want to be.

    • joshuakmurphy

      I am having the same issues in Gmail. I have tried this in both Chrome and Safari. It did work for me in Twitter though. What browser do you use Greg?

  2. Greg L. Turnquist

    I use Chrome. “j” and “k” seem to work. If you want to check, hit “?”, and see all hotkeys. Same for twitter.

    • joshuakmurphy

      When I hit “?” this showed me that I had keyboard shortcuts disabled. Thanks. That is really useful.

  3. Matthew

    Forcing yourself to work with a non-ide editor will also cause you to become more knowledgable about your programming language of choice, libraries, and other syntax and constructs that are typically auto-generated for you by your IDE. I like to use vim and scite for C, C#, and Ruby development all in different tabs at one time. For those who are uninitiated into the tradition of vi, check out vimcasts.org and yes I know that vim != vi, but its still a great learning site.


Submit a Comment

Your email address will not be published. Required fields are marked *