There’s a lot of good stuff being written about Vim and the way it can help you become a more productive programmer. Here’s my perspective on how Vim has made me a better programmer. ⚡
For those who don’t know, Vim is a powerful text editor that is often used in terminal environments. Since it is primarily designed for typing commands quickly into a shell, the keyboard-only interface can take a little time to learn.
I use vim-mode inside Visual Studio Code and vim inside the terminal for small files. If you want to learn vim try these exercises.
Vim allows me to code everywhere, on any operating system. Regardless of whether it's in an SSH session, in the terminal, on Mac, Windows, Linux or in a mobile phone.
It was one of the best productivity decisions I have ever made and my experience using it has been so positive and fun.
The Why of Better Productivity
Why do I use vim? Well, first off I’d like to talk about productivity and efficiency. I used to be a huge fan of /Sublime Text in the past but that has all changed since I’ve picked up vim. Why? Well, let me just give you a few examples.
Jump to line
Whenever you encounter an error, it shows a line number. For example line 5072. You can press the keys
5072G to immediately jump to the line instead of scrolling endlessly.
With one key press, you can also move to the beginning or end of the file.
Record and replay keystrokes
I use keyboard macros a lot. Vim lets you record and replay your keystrokes. Let's say you want to turn this into an HTML list:
spiderman batman x-men superman heman wonderwoman ... ..
All you need is to record keystrokes
qx for one item, and replay them
@qx. Even if that is for hundreds of lines. Saves you a lot of typing.
Sure, you don't have to use keyboard macros. But if you have a lot of repetitive work, do you really want to waste your life on that?
jumping the cursor
Vim allows you to jump between words. You can quickly navigates the cursor, much faster than pressing the cursor keys x times. With one key press you can move to the beginning or end of the line.
You can view multiple code files in parallel by typing
:vs. This works both in Visual Studio and in the terminal.
You can still use tabs at the same time if you want, but it's makes coding much more efficient 😄