Why Should You Learn Vim in 2020

Nikola Đuza
Aug 7 · 7 min read
Image for post
Image for post
Photo by Aleks Dahlberg on Unsplash

Ah, yes, Vim, the powerful text-editor that is everywhere and a place where even the wisest can’t quit. You had to hear about it at least once. Or you might have considered learning or trying it. But why do it now? It’s 2020, doesn’t everyone use VSCode already? Let’s dive in and figure why someone would still learn Vim.

From Mode to Mode

Most of the editors work in one mode. You don’t explicitly switch from one to another. For example, you might jump to a file, then select some lines, edit or copy some of them while being in the “same” mode. Vim is different, and it strongly differentiates modes. Maybe this is why most people get stuck in it from time to time.

Vim achieves all of this because it supports different modes:

  • NORMAL mode

How to get there? Press Esc key in any mode.

What is it about? Swiftly navigate through code and enter any of the modes below.

  • INSERT mode

How to get there? Press i (insert), a (append), or other keys from the Normal mode.

What is it about? Change and insert characters, similar to most editors nowadays.

  • VISUAL mode

How to get there? Press v, V, or <Ctrl-V> or other keys from the Normal mode.

What is it about? Highlight areas of text, indent large pieces of code,

  • COMMAND-LINE mode

How to get there? Starts by typing : in Normal or Visual mode

What is it about? A door to a Vim and outside world

There are other modes, a total of 12 of them. Six of them are a variation of other 6, but I won’t get into details about them here. You can read them here.

But Should I Care About Modes?

For example, one of my life-saver features is the ability to edit columns of text like this:

Image for post
Image for post

Notice how quickly you can select characters along a column. Please let me know if there is a way to do this as quickly and painlessly in other editors. To do this in Vim, press CTRL+v - now you can select columns. The following command is 8j, letting Vim know that I want to go eight lines down. Then, I press s to substitute a character, and I type in the character t, which I want to put there. Finally, I press Esc twice, and the whole column is changed. You can see that I then press u to undo my changes.

I didn’t know this initially, nor did I learn it in the first two years. I learned it when I needed it. So don’t get bothered if you feel overwhelmed by this vast world of Vim, everything will come with time. And that is another great thing with Vim, the constant learning — you can always uncover more great ways to do things.

The Need for Speed

Instead of having to use your mouse, you can use a combination of key presses that let you jump around the file with ease. For example:

  • gg - jump at the top of the file
  • G - jump at the bottom of the file
  • { - move up between empty space or code blocks (paragraphs) in your file
  • } - move down between empty space or code blocks in your file
  • ( - move back onto the previous sentence
  • ) - move forward onto the next sentence
Image for post
Image for post

These are just the basic movement tips you can try out in your next Vim session. I will not go into details on how to move around, and how you should disable arrow keys on the start (you probably should), there are many resources for that on the internet. I will just leave you with these couple of navigation shortcuts for you to try out.

Also, you can compose commands as you go. In the previous section, I used 8j to move eight lines down. Navigating like that is a typical example, but combining commands is where Vim shines when you get the hang of it. Combining is a great addition to already speedy commands you can use. But, of course, there is a more pragmatic reason to learn it. Read on to find out.

Learning Vim also means learning about what is in your Terminal and your machine. To better paint the picture of what I mean, I’ll approach it from the other side and give you an example of what you usually do with an IDE. When you use an IDE-like experience, you don’t need to tinker and configure stuff much. You get a theme or a plugin manager, you search for a plugin there, click install and voilà, you just got yourself full support for TypeScript.

But, setting up full TypeScript support is a bit different in Vim. Yes, you have a sea of plugins and a vast community of folks contributing to it. But you can get deep into configuration and figuring out how everything works by customizing your Vim experience. Some plugin has some pros and works well with others. Some are so good with fitting into your current configuration, but you have to do a lot of manual configuration yourself. By tuning Vim, you are learning more about what you have in your development environment and how it works.

For example, to search for text occurrences, I used ack-grep. Later on, I found that there is a faster approach using ag. Then, there is an even faster alternative called ripgrep. Of course, I stopped at the ag, but my point is that you are encouraged to learn more about what you have on your machine, and thus have more confidence and knowledge about what is happening. Learning all of this getting you closer to the metal (machine) as possible, instead of mindlessly installing plugins from the IDE's marketplace.

If you want to get a glance an what it takes to have Vim and TypeScript together, check out this blog post.

Some Cons to All of This

Another way to reduce the slope of the learning curve is to try out vimtutor. If you have a Unix OS, just type vimtutor in your terminal. Or, if you are a more visual person, try out Vim Adventures, where you can learn Vim by playing a game in your browser.

Keeping your favorite editor close to you is an excellent way to overcome Vim’s learning curve slowly. Imagine it as swimming lessons where you swim close to the edge of the pool. Anytime you panic or don’t know how to do something, you can grab the edge — or in your case, your editor of choice.

A con can be that Vim is not an IDE. It can’t do all the fancy stuff your IDE can do out of the box. You can try to configure Vim to behave like that, but that’s not Vim anymore. There’s no debugger, no plugin marketplace, no auto-complete. If you want some of the things, you are encouraged to search for a plugin or write your own.

Having such freedom of what to add to Vim is a pro for me, but I understand that most folks see this as a con. I just find it fun to play around and configure the primary tool I use every day.

Final Thoughts

At the end of the day, it’s the matter of finding the proper editor (tool) that makes you do what you do even better.

If you like the blog post, you can share it with your friends and coworkers below:

Consider subscribing to my newsletter, where you will get similar blog posts like this one when they get out, for free.

If you are interested in my Vim configuration, check out my dotfiles.

Catch you in the next one, cheers 🍻

Originally published at https://pragmaticpineapple.com.

The Startup

Medium's largest active publication, followed by +720K people. Follow to join our community.

Nikola Đuza

Written by

Freelance Software Engineer. Loves to create awesome stuff with Ruby and JavaScript. Find out more on https://pragmaticpineapple.com/ 🍍

The Startup

Medium's largest active publication, followed by +720K people. Follow to join our community.

Nikola Đuza

Written by

Freelance Software Engineer. Loves to create awesome stuff with Ruby and JavaScript. Find out more on https://pragmaticpineapple.com/ 🍍

The Startup

Medium's largest active publication, followed by +720K people. Follow to join our community.

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store