The first time I encountered vim was during a Linux System Administrator course I attended a while ago.

Didn’t really know much about Linux back then. It just sounded quite fancy.

During the course, the lecturer often typed in that 3 word command vim and edited some stuff.

“Gee, that looks cool”, I thought!

So, determined to look cool myself, I got back home, opened a terminal, typed in the magic words and voila! – I was inside vim.

So, with a great wish to write my first Hello World txt file in vim, I started hitting keys on my keyboard. And nothing was happening.

Some strange beeps started coming out of nowhere and I felt utterly frustrated!

So, my goal quickly shifted from typing anything, to exiting vim. Yeah, you probably know what follows.

A key-hitting berserk got me while doing everything I can to exit vim. Finally, after failing my first clash with the editor, I was so thankful to have the X key at the top right of my terminal emulator.

Now, this story should sound pretty familiar if you ever tried using vim. Well, eventually you learn how to exit it, and you learn how to type in symbols.

But there is so much more to it. The endless sets of key-combos can leave you wondering what the heck you did after accidentally hitting a key.

Nowadays, vim is the most popular text editor out there. Even some Windows users tend to use it although being an indigenous Unix utility.

But what’s the point? There are so many IDEs out there. Why would anyone bother poisoning his life with an endless vim frustration, when he can just install the first Javascript IDE google suggests.

Well, although it is probably not suitable for any project, there are some great benefits in sticking with vim at least for a while.

The greatest one being the user interface. However, the focus of this article is not that. Many articles can be found on the subject and perhaps I will make one in the future.

Today, we will explore the much less highlighted merits of the vim editor.

Curing the IDE illness

The IDE is a great tool. It gives you some pretty cool features on the get go – auto-completion, code templates, code snippets, etc.

These things are irreplaceable, especially for big projects. But they can also greatly cripple the skills of programmers who have never used anything else. The reason is that by using such utilities, you become sloppy in your writing, because that function call is one tab away from auto-completion. Also, you might be surprised what gaps you might have developed in your knowledge due to these tools.

I am such an example. There were two instances when I was amazed by my short-comings due to the IDE illness.

One time, I was an assistant during a programming course and one guy asked me for help in one of the first lectures of a programming basics course. He had created a new VS template with a Hello World C# program, but he had messed up the initial C# code and it wasn’t compiling.

So, he was asking for assistance to get that fixed. I tried doing that, but then I was amazed that even I didn’t know how to write a basic C# Hello World program without relying on the standard template. In the end, I told him to delete the project and make the new one, so that VS creates the Hello World template for him.

That came as a great surprise to me. I was so used to the default Visual Studio C# template, that I wasn’t able to write it myself.

Another such instance was when I tried to write a for loop without using auto-completion, the first time I tried vim. I couldn’t do it. I didn’t know what went where in the loop declaration because I had always used auto-completion to write the for loop for me.

Now, you might think that happened very early on in my programming experience, but you are wrong. I had already learnt what OOP is, several programming languages and some basic data structures. I had been programming for nearly a year and yet, I was unable to write a for loop on my own.

With a basic vim, you don’t have auto-completion and default templates. This way, I was able to detect these shortcomings and amend them.

And what’s more, being required to write the whole function names on my own, I was able to become an extremely fast writer. Now, I feel the keyboard as a continuation of my hand.

That doesn’t mean I don’t use auto-completion and templates in my projects, though. I do use them, even with vim (when I set up some plugins). They are great tools that greatly increase productivity. But I believe one should spend some time creating projects without these utilities in order to feel the gritty experience of writing the entire code on your own.

This will definitely make you a better developer. What’s more, many companies use whiteboard interviews to test their candidates. If you are unable to write a hello world program without auto-completion, all your algorithms knowledge won’t help you on the whiteboard.

Removing the layers of abstraction

When using an IDE, everything is one-click away. You can compile, link and run your project by clicking Ctrl-F5.

In reality, those are three different commands.

From time to time, you can spot a loading bar in the bottom of your IDE, with a status message Indexing.

Do you know what that is?
Why is it done?

And did you know that in order to build your project, the IDE uses a configuration file, that outlines how the individual files are to be compiled, linked, how to run the tests, etc?

The exact application of the configuration file is project-specific, of course, but it is possible to configure all these properties.

If you don’t use an IDE, you have to write this configuration file on your own or generate it explicitly (Makefiles are example of this in C/C++ projects).

And by using an IDE, these details are hidden which saves time, of course, but leaves you with a lack of knowledge again. Some might say that you don’t need this knowledge if you don’t encounter it in your day-to-day job.

Car mechanics can get away with not knowing how the engine works if they are only substituting car parts in their job. Does that make them masters of their craft?

But by using vim and the terminal, all these intricacies are not hidden from you and you have to explicitly do them. This takes more time to an apprentice, but lets you explore the capabilities of your system.

For example, did you know there are compiler options, different from your IDE defaults?

Another thing is that using this approach makes your project more portable as you are using universal tools, not IDE specific ones. One problem I have encountered with this in my experience was a very old project, which was required to be ported to a different IDE.

I had to delve deep into VS specific configuration files in order to reverse-engineer the build system of my project. By using a Makefile, for example, you can simply import a Makefile Project in any modern IDE and you have your project ported out of the box.

 An Ocean of IDEs

For C#, you have Visual Studio. For Java, there is Eclipse and IntelliJ. Python has PyCharm. And there’s C++’s Code Blocks.

Even if you stick with a single language, there is a chance you will still have to switch IDEs between projects you work on.

So why is this a problem?

Well, by constantly switching tools, you have to go through learning that IDEs shortcuts and key bindings. Many don’t even bother and go on using the mouse and click click click.

That means that your productivity won’t be as high.

Also, running an IDE is tough on your laptop. I have had instances of having CLion open for a C project, IntelliJ for Java and PyCharm for Python.

If you have an old laptop, like me, then that won’t be a pleasurable experience.

But even so, I am bothered with having to use different tools for different languages. Every tool has its own intricacies and shortcuts.

Having to IDE switch all the time, leaves you with using only the least common denominator utilities of each IDE because you can’t learn them all.

By using vim, you have one editor to rule them all. And you have the same shortcuts and key bindings on different languages.

But using vim can be bothersome on some projects, though. For example, C# projects are pretty coupled with Visual Studio and you will have a hard time if you try substituting VS for vim. However, what you can do instead is use a Visual Studio plugin to emulate vim inside VS. That way, you can have your favorite shortcuts inside your preferred IDE.

A similar plugin is available for the other major IDEs as well.

vim can get fancy as well

Using bare bones vim is beneficial as outlined in the “Curing the IDE illness” section. But for big projects, I’m a fan of using plugins to match IDE-like behavior simply because navigating a code base can be much easier.

This is a screenshot of my custom tuning of vim:

It has many great features and using it, I was able to entirely substitute CLion for a quite big C code base.

In a new series of articles, I will start exploring my favorite vim plugins and explaining when they are useful and when they are not.

But if you’d like to have an IDE-like vim, you can clone my dotfiles repo and run the install.sh script. It will configure the exact vim configuration I use now.

Note that there are some non-vim related configurations in there, but you can easily extract the relevant things. I have left comments explaining what each part of the script does.

Conclusion

Apart from vim’s lovely user interface, there are other benefits to using it at least for a while. If you’re too used to your IDE’s code templates and auto-completion, it’s time to give vim a try. Be warned, IDE illness is not to be taken lightly.

Furthermore, if you’d like to take a sneak peak behind the abstraction the IDE provides you with, it’s time to open the terminal and create a project using vim from scratch. You might not like the editor, but the knowledge you will gain is priceless.

And if you are sick of using 5 different IDEs for doing your job, vim can be the right option as well. It grants you a single set of tools, portable for different projects.

So what are you waiting for?

sudo apt install vim and start your journey with this great editor.

Once you do that, whether you like the editor or not, it will make you a better developer.