Level Up Coding

Coding tutorials and news. The developer homepage gitconnected.com && skilled.dev && levelup.dev

Follow publication

VIM is not only about speed

--

Yep, spending days to become a few seconds faster is silly, but that was never the point

One common misconception I see being made all the time about Vim is that the only reason why we use Vim/NeoVim is to be able to write code faster. It may sound a bit silly to climb the mountain that is learning Vim just for this single benefit and indeed I would say this is silly. But this is not the only reason we do it.

The truth is we all learned Vim to be able to say “I use Vim by the way”.

Porky Pig with the saying “That’s all folks!” above and “I use Vim by the way!” below

Not really. I mean, both the speed and memes are cool reasons to love using Vim, I just don’t think it’s enough to justify learning it. My intention with this article is to provide insights into what makes people cling to a supposedly ancient editor that only made sense when people could do nothing on a PC but write green text on a black background.

Disclaimer

Before we start on this journey I must make clear that my first experiences with Vim were just as smooth as nearly everyone else.

First I opened it by accident while typing “git commit” and made the mistake of forgetting to type “-m” and a message before pressing enter. This resulted in me having to close my terminal as expected.

Then some time later I — out of curiosity — decided to check what it was about and learn at least the very basics of it to understand what was the point of it. The result of this was me trying every possible combination of keys possible and managing to do every imaginable action an editor possible could — except doing basic things like writing “Hello World”.

Meme comic story with two frames — the first has man reaching for a ball with the name Vim and the saying “Me trying to learn vim” on the man. The second frame has a monster with the saying “Realizing no characters appear when I press keys” hoding the man that was trying to reach for the ball.

Only years later would I finally decide to effectively learn how to use Vim motions (initially I did this with VS Code’s Vim extension) and eventually join the club of degenerates who swear by a tool no one else around them uses. I reveal this to you all in the hope that you will realize that if you think Vim is pointless, outdated, or just weird you’re not the only one — we all thought that before learning the ways of Vim.

The reason Vim is awesome

So, hear me out, the reason why I love Vim so much is not actually about raw speed — as in taking a few seconds less in each action or just having to press fewer keystrokes. It’s all about flow. It’s not just that we can write faster, but the process of thinking about what we have to do and effectively doing it is just way smoother.

One analogy I like to make is having to go from point A to point B and having two separate ways to go there. The first way is like a maze crowded with people everywhere bumping at you every time and is full of choices you have to make and many of those are dead ends, so you have to keep your focus on getting to point B to avoid getting sidetracked. This is how I feel using an IDE nowadays — I can get to point B indeed, and will even get there quickly with the experience I have nowadays. It’s just not pleasant at all. And it can become quite exhausting if I have to take this way constantly and always in a hurry.

AI digital painting of a crowded city full of signs pointing everywhere
The process of me navigating IDEs with the mouse as rendered by Dall-E 3 (because it takes time and effort enough writing this article without AI for the text)

The second way is like a walk in the park — there might be some distractions if you look around, but they are often pleasant and you won’t even realize they’re there if you’re focused. This is how Vim-motions feels to me. I can see my destination easily and it’s a clear path to get there, so if I have to go faster, it’s just a smoother ride.

AI digital painting of a beautiful park with a lake and many trees.
The joy of navigating code on my tmux + NeoVim setup as rendered by Dall-E 3.

Even if both ways took the same time to get from point A to point B I would still prefer the second way because it’s just more pleasant and less draining. But it turns out that Vim-motions is not only smoother but faster as well so that’s why most people who learn it well often stick to it.

Keep in mind I mentioned Vim motions here, not Vim, because some people come back to editors like VS Code or IDE’s like the ones from JetBrains after using Vim/NeoVim for a while — but most will still use Vim motions on them because it’s just better. To anyone who doesn’t know Vim (and its spiritual successor, NeoVim) are command-line editors, that run directly on the terminal. And the way you navigate and edit the text in it (which we call Vim-motions) is so effective that many extensions and plugins emulate this behavior on other editors and even IDEs. What I want to focus on here are these Vim motions because I think this is where most of the value of Vim lies.

Suspicious Fry from Futurama meme with the sayings “But these so called Vim motions are counter-intuitive” above and “And you’re telling they are the best part?”

Well, being user-friendly is a complex matter, and being beginner-friendly is just one side of it. Vim is not beginner-friendly, this is pretty much common sense. But there are other aspects of the user experience that in my perception make Vim an amazing experience for advanced users that other tools don’t even come close to. And often what would be intuitive to a beginner can be slow or bothersome to an experienced user.

Take a word processor like Microsoft Word for example. It has icons that often show exactly what they do, like an underline button that is an U with an underline or an italic button that is an I on italic — this makes it way easier for a beginner to use the software because many features can be discovered by simple exploration. However, if you’re writing an essay it would be unlikely that clicking those same icons whenever you need to style something would be practical — if you need to style things often enough it’s much easier to learn the shortcuts like ctrl+u or ctrl+i. What makes it user-friendly is that until you learn (or even need) the advanced commands it guides you by the hand to do whatever you need to do. And when you learn the advanced commands, you become quite efficient.

Vim on the other hand… It’s like the Dark Souls of text editors. It’s like the incarnation of no pain no gain — there is no learning curve, it has a learning mountain behind the great wall that you have to climb. But on the other side, after you start climbing this mountain you will realize it gives you a level of productivity you simply can’t find on easier-to-use tools. It starts to feel even more intuitive than the traditional way of editing — and after you understand its mechanics it’s amazing just how powerful you become.

Skeptical third world kid with the sayings “So you’re admitting Vim is not beginner friendly” above and “but you want to convince me it’s intuitive?” below

I can see how this can be hard to grasp, but bear with me for now. What makes Vim so hard for beginners is that it is different from most other tools in the way it lets you interact with text — so you have to understand how it works before you can even realize what’s going on. And while you’re learning the basics you will indeed find it way harder to do simple things because of how different it is. After you start getting the hang of it becomes easier and easier to do not only what you could do before, but also to learn new things on Vim.

Take deleting a word, for example. When you’re first learning Vim you learn that you can delete a word by moving the cursor to the beginning of the word and pressing `dw`. Then you discover that `d` is the delete action and `w` is the movement (which tells on what part of the text to apply the command). Then you learn that you can use other movements with the same delete command like `d$` to delete to the end of the line of `dj` to delete the current line and one below (`j` by default moves the cursor to the line below).

Animated gif showing the ‘d’ motions of VIM

So far it may sound like you have to memorize many specific commands to do specific things but let’s say now you have to copy the text instead of deleting — for this you have to learn the command `y` (yank) and this is it — if you already know `dw`, `d$` and `dj` you can now copy to the end of the word, to the end of the line or the current line plus the one below just by changing the d to y: `yw`, `y$`, `yj` all work like you would expect them to.

But then you learn of more advanced movements that use text objects like the `iw`, `ip`, and `i)` (text inside a word, text inside a paragraph, and text inside parenthesis) for example. By learning just these 3 new movements you can now both delete and copy all the text inside the word, paragraph, or parenthesis that the cursor is in, even if the cursor is in the middle of the word or the paragraph or anywhere between the opening and closing parenthesis, just by prefixing the command with d or y.

Animation showing some ‘y’ motions of Vim in action

Now let’s say you just need to change some text to be all lowercase and you discover online that there’s a command `gu` that does that. You can use this new command with any of the movements you learned before just by just changing the command — `guw`, `gu$`, `guj`, `guiw`, `guip` and `gui)` work exactly like you would expect. And if you use `gU` instead `gu` it changes it to Upper case.

Animation showing some gu movements of vim in action

But now let’s say you are good enough with Vim that you just want to show off. You can install the surround.vim plugin by tpope and just blow people’s minds with things like `ysip}` (`ys` being “insert a surround”, `ip` being the movement inside a parenthesis we learned before, and `}` being the character you want to insert surrounding the text).

Animation showing some advanced vim motions including some from surround.vim

If you’re not a Vim user and this looks too much to handle all at once, don’t worry, it is indeed too much to learn at one time — the ideal way to learn Vim is to learn just the basic commands like `d`, `c` and `y` and get the hang of them first with simple movements like `w` and `e`. Then as you become used to them and they become muscle memory, you start getting used to more movements. The good part is that each thing you learn adds to your toolbelt and can be used together with what you learned before.

And that’s why Vim becomes intuitive: it’s indeed hard to start learning it, but after you start it every little thing you learn expands your capacity exponentially.

Confused lady/Nazaré Todesco meme with the sayings “But what is the relation between this” above and “and the flow you mentioned before?” below

The thing is that Vim motions often feel more like a language you speak rather than a set of shortcuts you use — the more you use, the more you find alternative ways to say the same thing that comes more naturally.

When you’re learning a language like Portuguese and you want to order a bottle of water in Brazil you may have learned to say things like “Por favor, você poderia me trazer uma garrafa de água?” (Could you please bring me a bottle of water?) and you would probably have to stop and remember each word as you’re saying the first time around.

After you get more fluent in the language sentences like “Eu gostaria de uma água sem gás” (I would like bottled water) or “Me dá uma água sem gás, por favor” (give me bottled water, please) may come more naturally and will basically get the same result. And sometimes you’ll hear natives saying things like “Uma água aqui, meu chapa” which might also get the same result in an even shorter way but depends on things like intonation, context, and body language — just like using someone else’s Vim configuration might feel completely foreign.

And this is part of the beauty of Vim motions — as you use it some commands and movements become muscle memory and then you start getting new ways to do what you think more effectively. And the more you learn it the easier it gets to do whatever you’re thinking.

Also, people have a misguided idea that Vim will allow you to write faster and that this is something that would be better done with things like autocomplete, refactoring tools, snippets, or even a tool like a co-pilot instead of switching to a different editor. The truth is that you can (and probably should) use all this on Vim (especially NeoVim) too — they’re not mutually exclusive. And most of the productivity gains of vim motions are not from writing, but from editing.

Copying a chunk of code to paste somewhere else in the code, changing just a parameter from a parameter list on a function, or even completely overwriting the contents of a function are way faster/smoother to do in Vim than they would be in a mouse. Also, by using the keyboard to do this you can keep your hands on the home row and be in “typing mode” immediately — while if you’re using the mouse you have to reposition your right hand on the keyboard for proper typing.

These little movements like moving from typing mode (hands on home row) to mouse navigation (left hand on the keyboard, often near the left ctrl and right hand on the mouse) to keyboard navigation (right hand near the left ctrl and right hand on the arrow keys or navigation keys like HOME and end) may seem too tiny to make a difference when you focus on speed alone but they add up as a cognitive cost to do every action you make and removing this small steps can improve the flow between thought and working code on the long run.

Willy wonka meme with the sayings “So now is the part where you say Vim is the only way” above and “and everyone else has to be enlightned?” below

Well… Not exactly. Vim/Neovim as a text editor is an excellent choice if you want the smoothest experience with Vim motions and you’re willing to go the extra mile to get the ideal environment for your personal needs and development style. But they’re not for everyone, especially if you shiver at the idea of spending any time configuring and getting used to your editor rather than just writing code.

For most people, I believe Vim motions inside your favorite text editor are the best way to go since it provides most of the power of switching to Vim without most of its trouble. And if you ever want to become blazingly fast you will already know most vim motions so the switch to actual NeoVim will be much easier.

So I do recommend that all developers eventually try learning Vim motions on their editor/IDE — at least the very basics of it. That way you can start learning how to use the power of Vim without compromising too much on setting up something you don’t even know you will like (though you will like it, trust me).

Please clap if you think this is useful information and follow me if you want more content like this. I write about development and tech in general. And I use NeoVim by the way.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Written by Thomaz Moura

I’m a senior .NET developer and VIM enthusiast and I just love sharing knowledge and my experience with other people.

Responses (36)

Write a response