Why Using Vim Will Improve Productivity
I’ve always been a casual VI/VIM user, I cut my teeth on FreeBSD as a server operating system and it was a guarantee that it would be installed. I learnt the basics of navigating around and editing and I did okay updating configuration files and paging through log files. I never adopted it as an editing tool, in fact up until recently I wrote off editing platforms that didn’t offer the power that a fully integrated IDE brings. In short, no auto-complete then I wasn’t interested.
Then I started seeing people switching to VIM on my social media feeds more and more and I gave it one more go, except this time with feeling. It took two days before I really started to feel the difference but if you’re a complete novice then I would suggest giving it a week. Don’t quit from the steep learning curve, don’t quit because you initially think it’s slowing you down, it probably is, but perseverance will result in a faster editing workflow.
What properties of VIM lead to this, in summary, you don’t use the mouse. Using the mouse is the biggest inefficiency of getting your code into the machine. If we just take a moment to look at the cognitive steps of, selecting all content inside a function prototype’s parameters and overtyping:
- Find mouse with hand
- Identify where the cursor is
- Identify where the function is on the screen
- Position mouse at start of parameters
- Click and drag to the end
- Start typing, unless you need to delete more due to inaccurate selection
Too much time is spent identifying the location of items, in the real and virtual worlds and with the inaccuracies of selection on computers you end up doing additional typing, careful selecting or reselecting. If we compare this with the equivalent task in VIM:
- Move caret within function prototype parameters, doesn’t matter where.
- Type “ci )”
- Start typing
VIM is just full of these quick and intelligent ways of performing tasks and it’s all of these that you need to learn to get the most out of it. It’s this daunting process that puts most people off. Assuming that I’ve convinced you to give it a go, let me outline how I approached enhancing my VIM knowledge to a more productive level.
Firstly, don’t try to learn it all at once, don’t download the cheat-sheet and scare yourself. Learn what you need to know as you need to know it. Firstly learn how to move around your code, enter insert mode and delete code. These are the basics and once you’re up and running and the keys are familiar then start questioning how you’re working, chances are there’s a better way. Like the example above, you could delete all the characters one and a time or you can issue a command that wipes everything in the brackets and puts you in edit mode. When you think you’re being inefficient, skip the thought that VIM is rubbish, do a quick search, no doubt you’ll find a much better way of doing it, i.e.
- Multi-line indent (2»)
- Overtype all content until the next whatever character (ct ,)
- Overtype all content within quotes, brackets or angle brackets (ci “)
- Remove the carriage return between two lines (J)
These are all things that have greatly improved my productivity writing code.
As an aside, there have been a couple of other things I’ve discovered on my VIM journey:
- My classes are becoming smaller due to the fact I don’t want pages of code to page through when navigating with a keyboard.
- VIM supports many plugins, which include auto-complete and projects
- Someone has ported VIM to Java and made a plugin for Netbeans
The last one I’m loving at the moment, as I am getting all the power and familiarity of Netbeans while learning and editing using VIM syntax. In the end I could look at more and more plugins for VIM so that editing on a remote machine is as good as using an IDE, but one thing at a time.
- VIM will ultimately improve your productivity
- Learn it gradually
- Every time you’re thinking it’s slower than reaching for the mouse, search for a solution.
Developer, musician and gamer; I love all three and have time for one. It's our work that proves our worth, not our words!
Senior developer at Tonik Energy