It's time to get over the vi addiction

February 21, 2017

It's time to get over the vi addiction

Hi, my name is Arthur (Hello Arthur!) and I'm a vi addict. It's been six days since I last used vi. Last week, I had a list I was trying to move from...

Hi, my name is Arthur (Hello Arthur!) and I’m a vi addict. It’s been six days since I last used vi. Last week, I had a list I was trying to move from a PowerPoint into another application and formatting kept getting in my way. I started up trusty vi, hit “I” and pasted the text in, then re-selected it, copied, and pasted into the target application – sans formatting as desired. Before that, my last stretch was nearly a year.

When I was first introduced to vi twenty-five years ago, I hated it. It was wonky, ugly, and had no user interface (UI). Then, I started learning it and it became my mainstay editor for everything I touched. It’s an easy transition for those who already know how to type, and once you have the whole insert mode/edit mode transition down, life is great. Soon you find yourself typing extraneous j’s and k’s in any other editor you use. (If this doesn’t make sense to you, this article isn’t for you. Seriously, do NOT learn vi – it’s too dangerous.)

Why do I think the time has come to stop using my old favorite? For me, it was the transition to Eclipse. I first started using Eclipse because our tools integrated with it. Not having vi keystrokes drove me crazy, so I installed a variety of plugins to make the editor behave like vi. At first it was pretty awful, but some of the plugins worked reasonably well, as long as you didn’t want advanced vi features.

Initially, I worked in a hybrid mode where I’d either use the finicky vi mode in Eclipse, or edit in a separate vi terminal and build in Eclipse. Then the autocomplete, code formatting, code docs, quickfix, full project search, templates, etc. began to win me over. The plugins, such as tools to deal with jdbc sources and UI layouts, made my life easier. At some point, I started to realize that I was behaving like a dinosaur – unable to adapt to the new climate. When I was writing code in Eclipse, I was working much faster with fewer problems, so I trained myself off vi keys and back to “normal” editing.

Now, as we all know, vi and its stepsister Emacs both persist mainly in the embedded space. Yes, it’s true that old engineers can type quickly and efficiently there, but the other tools that help produce high-quality code remain outside their reach. Therein is the second problem with these old editors: you end up not using all the latest tools and techniques that allow agile (small “a”) developers to blow right by you. When analysis tools run, can you click on an issue and have it take you to the correct file and line number? Can you right-click and get information explaining what is wrong and how best to address it? Or do you end up reading an email to check the results? The 90s called – they want their editor back. You should let them have it.

I’ve helped more than a few people break their vi addiction. The simplest way is a one-month challenge. Give your whole heart and soul to using a new code-centric development environment, set it up properly, learn how to use it, and do some real work with it. If you don’t find you’re more productive, then switch back – but give it a bit of time, because so far this method has had a very high success rate. It’s tough to recognize when the tools in your world have changed and you’ve fallen behind, but you can do it.

I started off by saying it’s been only six days since I last used vi, and that’s true. Now I only use it when it has a real advantage, like for regular expressions or config files. What it doesn’t do well is code. Come join the rest of us – leave vi to the sysadmins where it belongs and bask in the warmth of an editor that knows and understands the programming language you’re using.

Arthur Hicken has been involved in automating various practices at Parasoft for more than 20 years. He’s worked on various projects involving the software development lifecycle, software security, complex web applications, and integration with legacy systems. Arthur taught at the College of DuPage in Illinois, as well as developed and conducted numerous technical training courses at Parasoft.

Arthur Hicken, Parasoft