Vim - I hate to love you
Published on 2020-04-07. Modified on 2021-01-15.
When I migrated from Microsoft Windows to GNU/Linux and FreeBSD back in 1998/1999 I cannot remember what text editor I was using for software development, but I do remember using Quanta Pro and Kate at some point for web development. Later I began using terminal applications almost exclusively because it's just so much more efficent, and I eventually also did all my web development in the terminal. At this time I kept it simple and used mostly nano and mcedit. I was quite satisfied with the simplicity of these editors and continued to use them for years. Whenever I needed to do more advanced search and replace I used
sed. This worked just fine.
Then one day a friend advised me to take a look at a "real" editor, as he called it, and he recommended Emacs. He also recommended Emacs Rocks and I was naturally surprised at some of the amazing stuff you can do. I decided to give Emacs a try, but after about a week or two I couldn't take it any longer, Emacs was unbearably slow and required a lot of plugins before it was really useful. So I began to look for other editors with similar capabilities.
Then I found Vim!
The modal aspect of Vim made sense to me and it was very fast and efficient even with very big files.
I decided to use Vim exclusively in order to become more efficient with it. I printed out a cheat sheet which I placed beside my keyboard. I also took the Vimtutor and watched a bunch of YouTube tutorials.
Since then Vim has been my favorite text editor and no matter what editing work I am doing, I use Vim. I have done tons of coding in Vim as well as written countless articles, books and documentation.
But all was not well with Vim and me.
I noticed that despite the fact that I had been using Vim for quite a long time, Vim still required mental effort on my part to use the editor!
The problem is that many Vim users swear to the increased productivity that Vim provides, yet few Vim users actually realize that they are not really using Vim! Instead they have stuffed Vim full of plugins and a thousand lines long
.vimrc file that completely change how Vim normally works.
The tutorials I had been watching were crap, but I didn't know that at the time!
Many Vim users also repeatedly state that Vim is only hard to use at first but when you really learn it, you become very productive. The problem with that statement for me was that I found myself just as productive when I used a simple text editor and
So I could not help myself, I started agreeing with Adrien Lucas Ecoffet when he said:
Vim users (I am not one of them) will tell you something along the lines of "it is hard to use at first but when you really learn it, you become super productive".
However, the second part of this sentence applies to just about every good editor out there: if you really learn Sublime Text, you will become super productive. If you really learn Emacs, you will become super productive. If you really learn Visual Studio... you get the idea.
Here's the thing though, you never actually need to really learn your text editor... Unless you use vim.
And I thought that it wasn't that I didn't grok vi, how could it be? I had read a lot about Vim and had watched a lot of tutorials.
Selecting stuff between parenthesis or brackets, utilizing marks (bookmarks), and jumping between specific characters in text is something Vim excels at, but at the same time this hardly counts as being super productive just because you can do that in a couple of keystrokes rather than holding down the shift key while pressing repeatedly on the arrow keys.
I also knew about people who still didn't know basic stuff you can do with Vim even after having used the editor for many years.
After all, what other text editor requires you to have cheat sheets and yellow sticky notes hanging around for weeks, months, or even years besides perhaps Emacs?
And I would actually go so far as to state that Vim sometimes even decrease your productivity. Yes, I really said that!
The reason I said that was because during the time when I used the really simple editors, all my mental energy was spend concentrating on the problem I was trying to solve with the code I was writing. No mental energy was ever spend on navigating the code or editing the code.
In ten years you can master multiple programming languages yet still find yourself discovering things about Vim you didn't know were possible or even existed! And why is it that something as simple as a text editor requires a 3.522 page long help documentation? Don't get me wrong, the documentation is amazing, but 3.522 pages? Is it an instruction manual to a Boing 747? How can something as simple as text editing require a 3.522 page long documentation? This just isn't right!
But the fact is that Vim isn't simple. Not by a long shot. And Vim is perhaps one of the most bloated pieces of software ever created. You have not one way to do a specific thing but sometimes almost a hundred different way to achieve the same result.
And no, the utterly ridiculous basic navigation with the
l keys, as well as several other key relations, has absolutely nothing to do with keeping your hand on the so-called "home row" and being efficient in typing, as a lot of people would like you to believe, this is just a side effect. It's a remnant from the old terminal keyboards. Notice also where some of the other "most used" Vim keys are located.
In time I have slowly realized why Linus Torvalds criticized Linux distributions he had found difficult to install.
I'm sorry, you may want to close your ears now, I want a distribution to be easy to install, so that I can just get on with my life, which is mostly kernel.
Linus called Debian a "pointless exercise" as the point of a distribution is to make things simple and easy to install. Now, I have personally never found Debian difficult to install, but I can certainly understand what he's talking about. Today I spend perhaps more than 95% of the time in the terminal emulator and I do feel quite productive, even more than I used to be with the software I used in the past, but all this has come with a price.
I remember back when nano and mcedit were my favorite editors, perhaps I wasn't able to perform all the amazing things I am with Vim today, but on the other hand I lived in blissful ignorance not knowing any of the crap I know today and I was focused on the work I did, not on the tools I was using to get the work done. This was not only much more minimalism at heart, but it was in fact in many ways also much more productive.
Anyway, the big Vim aha moment was when I finally realized that I actually didn't "grok vi"! I had been reading the wrong blog posts and watching the wrong tutorials - none of these people really groked vi either, and they where just passing along all their bad habits.
Why is it that some people do things just because they somehow believe it is the cool thing to do? There is absolutely nothing cool about whatever the &#%!@?! text editor (or operating system for that matter) you're using!
The most important thing to learn correctly about Vim is to understand that you talk to Vim when you edit text. Vim has a grammar. The next important thing is to learn how to use Vim macros.
If you're editing a big file with many similar, but very complex changes, you can record each edit you make, including whatever complex regular expression you're using, and you can replay those macros across the text everywhere the same type of edit needs to take place. And this is one area in text editing where Vim absolutely shines. You can literally do stuff in minutes that would take hours in a regular text editor, even in more complex and modern editors such as Sublime Text or Visual Studio Code.
If you ever decide to use Vim, know that the complexity is there for a reason, using Vim is almost like "casting spells" :) Every day you try to improve, become better and more efficient, and once you really get it, once you really reach that "aha moment", you will never look back.
A sign or clue to when you have begun to really "grok vi" is when you almost completely stop using
visual mode, and you also stop navigating text in
Vim - I really hate to love you!