Vim has been around for decades and hasn’t changed much, which is why many people still use it today. It’s got a consistent set of instructions across all systems. That means you don’t have to worry about whether you should be pressing control or command when hunting for that keyboard shortcut. This consistency doesn’t necessarily make it the best tool for the job.
Why should you use Vim?
You can install Vim on just about any computer. Whether that’s a Mac, Windows, or Linux machine, it doesn’t matter. This makes it a reliable tool when you switch between different machines often. Simply type
vim file.txt in your terminal to open up your files for editing and use the same controls you are used to. I know the interface you get isn’t the most flashy, but you can spruce it up with different plugins. For syntax highlighting, use TreeSitter, and for code completion, try out Conquer of Completion. This brings your Vim editor a bit up-to-date with today’s standards for code editors.
Why shouldn’t you use Vim?
Besides the fear of being trapped in Vim because you can’t figure out how to quit it, there are a couple of reasons you might avoid using it. Modern code editors like Microsoft’s Visual Studio Code are widely used, and for good reason. It has a plethora of extensions you can install to help increase your productivity. I even wrote about one of the cool ones I found, Bracketeer.
Like Vim, VS Code isn’t designed for a specific language or operating system and can be a reliable tool for developers. It’s got a ton of keyboard shortcuts to make your development process quicker, and, with each of the extensions you install, you probably get more. Many of the shortcuts require using modifier keys like command/control, option/alt, and shift. It can be tricky to get your fingers in the right position to hit four keys simultaneously. Fortunately, there’s a solution to this problem.
Why not just use both?
As I mentioned, many modern code editors allow users to install extensions or plugins. The Vim plugin brings all the powerful commands from Vim to your favorite code editor. Now, instead of going to the end of the line and hitting command + delete, you can double tap your ‘d’ key to remove that line logging extraneous information.
Installing the Vim plugin doesn’t mean you’ve removed the shortcuts that came native with your code editor, and that’s a good thing. Something simple like moving a line of code around a file can be trickier in Vim controls than using your editor’s controls. For instance, one of the many ways to move a line up in Vim is by using
ddkP. This removes the line (dd), moves your cursor up (k), and pastes the line (P). To do this in VS Code, you simply place your cursor on the line you want to move and hit option/alt with the directional arrow (up or down).
It might be faster for an experienced user to use the Vim method. But, for us newbs, it can be easier to use our modifiers with arrow keys. The Vim extension in your favorite code editor can be a powerful combo, so give it a try. If you’re not sure how to use Vim, check out this post by a fellow Atom on some of the must-know controls.