Vim an introduction
Why Vim remains one of the most powerful text editors
Vim might be the most notorious text editor in existence. According to the latest Stack Overflow survey1, Vim and its popular fork, Neovim, collectively place second in popularity, just behind Visual Studio Code. Clearly, Vim’s popularity is undeniable. But why is that?
To my mind, two reasons explain this popularity:
- Legacy: Vim is ancient in the context of computer science. If you’re on a Unix system, there’s a high possibility that Vim is installed on it, and you can be quite certain that
vi
is. - Keyboard-Centric Approach: Vim is a text editor centered around the keyboard. While it’s not the only one, it is, to my knowledge, the one with the most complete and comprehensible approach to editing with only a keyboard.
Another, more cynical explanation, could be that it’s popular because it’s ancient and different, meaning old users don’t bother updating to modern IDEs. But I don’t think so. I might not look like it, but I am not old, and I use Vim. Furthermore, in my professional environment, I am strongly encouraged to use IntelliJ for some of my work.
Yes, Vim was born from the constraints of having no mouse—more accurately, its ancestor ed
2 was created due to this limitation. I believe this is why Vim is so different from other IDEs. While IDEs vary, their roots are similar, with differences mainly in features. Vim, however, is a modal editor, meaning that shortcuts and their effects depend on the mode you’re in, which can be confusing for new users. But why is Vim a modal editor? It’s because Vim focuses on editing rather than writing. As developers, we don’t write code like an essay; we edit, delete, copy, and paste step-by-step. That’s what we really do, and that’s why you should consider Vim—because it’s different, and you’ll learn something new and interesting.
It’s More Than Just Shortcuts
When people are first introduced to Vim, they often see it as a text editor with a convoluted way of avoiding the mouse, nothing more than an aggregation of shortcuts. While there’s some truth to that, learning Vim is more than just learning a lot of keybindings. Learning Vim is about learning a language.
A Language
To demonstrate my point, here is a simple function:
func something(n int) int { // ... }
This function takes an int
, does something, and returns an int
. For this example, let’s assume that I changed my mind about the parameter. How could I change it?
Well, I could go inside the parentheses and delete character by character using x
. That is not efficient. A better way would be to go to the parentheses and change inside, which translates to ci(
. Not that crazy, right? But see how it relates to a language. What if you wanted to rewrite the body of the function? Think for a few seconds… ci{
. This is the strength of Vim: everything is coherent and connected. In the same manner that learning a new word in a language gives you more than just a single new phrase, learning a new operation or motion in Vim gives you much more than just a new shortcut.
Learning Vim is first and foremost about mastering a new vocabulary—what might be called shortcuts in other editors—and a grammar that allows you to compose commands that reflect your intent. In other words, it enables you to edit at the speed of thought.
Highly Customizable
Vim is, as you might guess, blazingly fast. That’s important for an editor because it lets me go through huge files without fear. I can confidently open a log file to retrieve an error, search using a regex, and edit using the same regex, all without waiting a single second. That’s really powerful. The reason for this speed is, of course, its age—older editors had to run on older machines. But that’s not all. Vim is not an IDE, which means it comes only as a text editor, the best in class but not even close to the current IDEs. Yet you can make it an IDE. In fact, this might be the IDE for you. By design, Vim is easily extensible, and the community around it is highly competent, creating one of the most vibrant and extensive sets of plugins, even compared to Visual Studio Code. You can have it all: syntax highlighting, language servers, autocompletion, debuggers. And If you don’t need a debugger, that’s your choice! That’s your IDE. I’m not saying it will be easy; you will need to learn more than just the Vim keybindings. But that knowledge has a lot more value than for other IDEs. Why? Because IDEs come and go, but Vim stays. Learning Vim today might mean it’s the last IDE you’ll ever need.
Or not. Try something else. IDEs are similar but different. IntelliJ is a great IDE for Java with a lot of impressive features. Try it, and if you really like something there, there’s a good chance there’s a plugin for that feature in Vim.
Don’t get me wrong—a minimal text editor often requires significant initial setup, and some people legitimately prefer their tools to have been tweaked by others highly competent. They want to quickly start using it and then only, master it over time.
The Terminal as an IDE
But even if you don’t intend to change your IDE, learning Vim might be a great opportunity to make your life easier. Need a quick edit on a config file? Nothing is faster than Vim, especially if you are in a terminal. And if you are using SSH, you don’t have a lot of alternatives, and none of them are as powerful and versatile as Vim.
Furthermore, learning a terminal-based tool has a compounding effect. This effect arises from the core principles of Unix, which is centered around files and text. The ability to edit directly in the terminal using tools like Vim or Emacs allows you to fully leverage core utilities and access what is arguably one of the most comprehensive and robust toolsets on the planet.
Vim is not a relic of the past but a powerful, efficient text editor that continues to prove its value—and it might just become your future IDE. Its unique keyboard-centric, modal approach and extensive customizability set it apart from modern IDEs, offering a truly impressive level of control. Whether you’re aiming to enhance your productivity, explore new ways of coding, or simply need a reliable tool for quick terminal edits, Vim has something valuable to offer. Don’t let the initial learning curve deter you—install a Vim plugin in your current IDE and start uncovering its capabilities. You may find that Vim is not just another text editor but the last one you’ll ever need.
Stay tuned for our next conversations, where we’ll dive into the basics of Vim’s language and guide you on the path to creating your own custom IDE. This journey into Vim will not only make you a more efficient coder but also give you tools that will last a lifetime.
-
https://survey.stackoverflow.co/2024/technology#1-integrated-development-environment — If we add Vim and Neovim together, the combined usage is 33%, which is greater than Visual Studio. I am surprised by the value of Visual Studio, as it is, to my knowledge, primarily used for C#. I wouldn’t be surprised to learn that a good portion of respondents confused it with Visual Studio Code. ↩︎
-
A lot of the quirk of VIM come from ED, for intance the “/” for search or the integration of a sed like cmd or even the possibility to execute shell command using !. It’s quite remarkquable how impratical this editor is as it is like vim a modal editor, but without information on the cursor, you might append using
a
, like vim, but without imidiate knowledge of where you are, cumbersome indeed, but still powerfull as range operator with,
,like vim, do exist and enable the use of operator like delete with a lot of effency, it’s no wonder that ken thomson and denis ritchi as writen Unix using this editor. ↩︎