If you're not already using vim (or something similar), I highly suggest you try it out.
What is Vim?
Vim is simply a text editor, as are Sublime Text and VS Code, among others. Instead of being an application that you download and run, vim lives in your terminal. It's typically operated without the use of a mouse.
Basically, you can use various commands to navigate and edit text. For example, the basic navigation commands are:
h to move cursor left
j to move cursor down
k to move cursor up
l to move cursor right
You can launch vim by going to your terminal and just typing vim:
So... what's all the fuss about? Looks pretty ugly to me.
What All the Fuss is About
Although it seems useless at first, there are literally countless reasons as to why you should use vim. Let me talk about the most glaring ones.
Reason #1: Productivity
Because vim is keyboard-only and most of the essential commands can be completed using the home row, you end up with huge time savings.
At first it takes some time to get reach your original productivity level, but after that, it simply becomes the faster way to write code.
It's all about minimizing the time it takes for you to go from thinking "I want to do X" to actually doing X on the computer - and vim embraces that with open arms. You can create your own commands for just about anything.
As a programmer, you're going to be typing for most of your career. Let's say you spend ~4 hours writing code every day. If using vim makes you even
1.25x faster at writing code, then in 1 year, you will comfortably save over 150 hours of your time.
Combine this with the fact that vim can improve your productivity by much more, and extrapolate that over a long career. That's a lot of time. Yes - you'll need to invest time initially, but the benefits are a lifetime of savings.
Reason #2: Ergonomics
I've quickly come to learn the importance of ergonomics. Wrist injuries can be pretty detrimental to a career.
Primarily, moving your hand to reach for your mouse is not only slow, it also puts added strain on your wrists. Since vim is mouse-less, being able to plant your wrists in one position is great for comfort.
Another of the countless examples is that reaching for the arrow keys on a typical keyboard is just really awkward. Having navigation (the most common operation) rooted to h, j, k, and l where your fingers naturally lie is a lifesaver.
Combine this with an ergonomic keyboard, and you've got a great duo.
Reason #3: Availability
Learn it once, use it everywhere! Vim is guaranteed to exist on all Unix systems and almost all Linux systems. Need to edit a file through ssh on a server? Working on a different machine? It's always there for you ❤️
Reason #4: Customizability
Nowadays, most IDEs are highly customizable as well, but vim gives you complete control. You can pick which plugins you want and change the behaviour of just about anything.
Many of the popular IDE features like git integration, code completion, and snippets can be added through plugins.
Your vim configuration is specified using a
.vimrc file. Porting your configuration to a new machine is as simple as copying over this file.
Reason #5: It's Fun
Honestly, using vim is fun! It's simply become the more enjoyable way to work. I've been using it for years and still am nowhere near scratching the surface of its full capabilities.
It's just fun to look for better ways to do things in vim. It's a little hard to explain, you need to try it yourself!
I dont think vim can completely replace an IDE for some. Certain features are simply easier with an all-out IDE, even if they're possible in vim. For example, if your workplace uses an IDE, they might build extensions and integrations for your work on top of it, which you may miss out on. But that's okay - it doesn't have to be your #1 editor to make it worth learning.
If anything, some IDEs have options to enable vim bindings, so you can use vim-like commands while still using your preferred IDE.
Also, the productivity hit you take in the first few weeks is definitely a downside, but hopefully by now you're convinced of the long-term benefits of this one-time investment.
How to Learn Vim
The best way is to simply open your terminal, and run
vimtutor. It'll walk you through the basics on vim and give you a chance to practice.
When you first start, you'll probably feel a crippling sense of inadequacy. What was once so simple is now so difficult... Just stick with it and it'll come eventually! 😅
After that, I suggest having some cheat sheets handy and working on your .vimrc when you're more comfortable. Check out some popular plugins for things like autocomplete, snippets, and fuzzy finders. I also recommend using Vimium if you want to be able to use vim mappings in the browser.
Overall, even if you don't end up using vim as your primary editor, it's still a fantastic tool to have for any developer. 🛠