Why I switched to Vim as my editor
I’ve used a lot of IDEs during the years. Eclipse, Netbeans, IntelliJ, Visual Studio, just to name a few. In the last few years I’ve been an avid VSCode user and I still like it. But all these IDEs have something in common, they make you move your mouse. Don’t get me wrong, in VSCode for example you have a lot of keyboard shortcuts that are all customizable, but out of the box you can still do everything with a mouse too. That’s why for me, I’ve just never bothered to learn all the keyboard shortcuts.
My first contact with editors like Vim was in university where we’ve used it on server environments to edit files. During that time I’ve never even given it any thought that an editor like this can be used for coding. It wasn’t until last year, thanks to twitch streamer and youtuber ThePrimeagen, who I’ve discovered, that I became interested in Vim.
So what exactly is Vim?
Vim is a text editor that was first released in 1991, so it’s been in development for a very long time. The big gotcha in Vim is that you interact with it mainly with your keyboard through various shortcuts. As I’ve already mentioned, you can also have a lot of shortcuts in editors like VSCode, but you can’t use e.g. the “j” key as a shortcut in VSCode, because when pressing the “j” key, you would assume that it simply writes a “j” in your currently opened file.
That’s where Vim is different, because it uses so called modes for different tasks. As a user you switch between these different modes, depending on what you want to do in your code. There are 12 different modes in total, but here are the 3 most important:
- Normal mode: Is used for various editor commands, like navigating your code.
- Visual mode: Is used for selecting/highlighting parts of your code.
- Insert mode: Is used for editing your code.
In a modern code editor like VSCode and the like, you are basically in insert mode all the time. Vim’s default mode on the other hand is normal mode, which can’t change contents in your file. That opens up the possibility to basically use every key on your keyboard as a shortcut.
Navigating the contents of your file in normal mode, can for example be done with the “h”, “j”, “k” and “l” keys, which move your cursor one unit left, down, up and right respectively. Another example would be “u” which is equivalent to Ctrl + Z for undoing a change. See the difference? Where we need multiple key shortcuts in other editor, Vim can use single key shortcuts for the most important functionalities.
Why is it so hard to switch to Vim
Well first of all, it takes a long time to become fluent with all the keyboard shortcuts you’re learning. If you’re same as me, it’s probably gonna take take you a week minimum to be somewhat comfortable moving around files with the most basic shortcuts. And honestly, you’re pretty much never gonna stop learning new shortcuts, because there are so damn many, and everthing is customizable.
The other important thing though, is that if you just the out of the box Vim experience, you will not get far. This is where plugins come in, and believe me there are a ton of plugins available for everything you can think of. This is on one hand an awesome thing, because you can customize Vim in however way you want. Let’s say you’re unhappy with the current file tree your using? Just pick and try another one from the 213 available!
On the other hand this will become an endless journey. You will constantly fiddle around your vim config, trying out new plugins, customizing existing ones or even write your own plugins if your nerdy enough. To be honest, if you have set out on a journey the be a more productive developer by using Vim, you will never break even with the time you’ve spent customizing 🤣!
To make your life a bit easier, I would suggest using NeoVim though, since it supports writing configs in Lua, which is in my opinion a bit easier than writing Vimscript.
If you just wanna try out vim without any configuration shenanigans, you can try the following preconfigured vim derivates:
Just as a small preview, this is how my current NeoVim Setup after roughly 3 months of usage looks like:
Would I recommend using Vim?
This answer is gonna suck, but it depends. If you’re happy with what you currently have and have no problem using it till the day you die, then probably no. Are you one of these persons switching browsers every month just to see whats cool new stuff is out there, then definitly give it at least a try.
For me personally, I’ve set a personal goal to try out Vim for a month and here I am still using it. I personally love fiddling around my config files and trying out new plugins. Also, this may sound stupid, but you will reach the point where you use like 10 keyboard shortcuts in 5 milliseconds and start feeling like the best coder in the world. It honestly reminds of me of my MMORPG addiction times, where I would feel really good after every flawless combo I executed.
So TLDR: go try Vim, maybe you will like it as much as I do 😉