Well… Why not?
When I was first learning how to code, I switched between many different editors but I never settled for one. Don’t get me wrong. Notepad++ is great and all, but I just wanted something a little bit more… interactive. You may be able to see the problem.
The main interface of most text editors is:
- Use mouse to move cursor around and select things
- Type things
- Use extensions like autocomplete to make your life less miserable
There is nothing wrong with this. You don’t need me to tell you that, since most people have nothing to complain about. Personally, I find it much easier to think and keep my brain active when I’m doing things. I don’t even have an autocomplete plugin because typing out code helps me think and makes it easier to understand when I come back to it later. I get the opportunity to think to myself:
Hey, I remember writing that. It was super tedious.
This is a portion of my
.vimrc file. For the uninitiated, that’s the file you use for configuring Vim. The complete file is the result of about 3 years of customization and as far as I know, it pales in comparison to most Vim users. The possibilities are endless and the shortcuts can be assigned to complex combinations of tasks.
Admittedly, there are more than a few shortcuts and configurations in that file that I never even use, but part of why Vim is enjoyable to me is the constant experimenting — and sometimes, experiments fail.
Vim instances exist within the terminal. This means that you never need to leave the terminal to edit your files. With tools like
tmux, I can have multiple terminal sessions saved each with their own Vim instances, running processes, and tabs simultaneously.
My personal preference is to have one
tmux session saved for each project I’m currently working on. Each project gets one tab for Vim, one for any persistent processes, and one for my command line. Since Vim can do most things that the terminal itself can do, I can even use Git commands from within it.
Another huge benefit to using Vim is the fact that I can easily help others with their code. If someone’s customized the hell out of Sublime Text and needs me to quickly steal their computer and fix something, I can pop Vim open and make the edits (assuming they’re not on Windows).
But What About Me?
At the end of the day, I strongly believe that you should learn whatever you can get your hands on granted it doesn’t get in the way of more important matters. Don’t waste your time learning Vim if you urgently need to learn React, for instance.
That being said, I think that Vim suits a certain type of person very well. If you love to keep busy and find more efficient ways of doing things, Vim is for you. I acknowledge that speed isn’t necessarily the most important quality of a developer, but efficiency is. When you use an editor like Vim, you’re not only editing, but also always thinking of how you could do things differently.
Okay, but how?
There are lots of resources out there for learning Vim, but practice is often overlooked. Don’t think that reading a few articles like this one is going to magically make you good at Vim.
When you first start to use it, you will be cripplingly confused. Your fingers simply won’t be able to do what you tell them to. Your brain will say “Move the damn cursor up,” and somehow your hands will manage to replace four lines of code with part of the Bee Movie script.
This Vim Cheatsheet is an incredible resource. If you’re new to Vim, I would personally recommend sticking to one section at a time. Start with the Movement section. Navigating lines of text should be your first priority since using the mouse is no longer an option.
Vim Adventures is a very popular little web game that will teach you the basics of Vim controls and help you build muscle memory.
This Introduction to Vim Customization will guide you through the steps to making Vim look less terrible.
Overall, I think that Vim is a great editor and even if it doesn’t become your primary editor, it’s worth learning to use. It’s basically the only editor that is readily available on any Unix-based operating system and is extremely fun to edit in once you get the hang of it.