How I use vim to Edit Code Faster
Tags: vim, linux, productivity
Published: 2021-05-30 17:30:55

If you work in a programming language that is not C, C++ or a shell language then you may not be using the vim text editor. Vim is an acronym for vi improved and it has been around since the 1970s. 

Due to the popularity of Unix and Linux systems, vim has been ported to most operating systems which means that, with minimal effort, you can run vim on your own computer. 

Using vim is often described as “the best thing since sliced bread” and many people believe it makes coding easier. 

Learning vim is not something you can do overnight and you will only become efficient if you practice for some time. 

To practice vim, I recommend [this site](https://vim.is/).

## Why vim?

Before I discovered Vim, I learned to program using basic text editors like Notepad++. They are easy to use, but they don't have any function to make your programming faster. When I discovered vim, I was amazed by how much easier I could code with all the shortcuts and commands.

Vim is like a [shell](https://bsdnerds.org/what-is-linux-shell/), you need to learn the commands and shortcuts in order to use it efficiently.

![vim keyboard](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p5jjfy7sb19ruzukmoyt.png)

You can use shortcuts like `dd` to cut a line, `yy` to copy a line, `p` to paste etc. You can press a number to repeat the action, like `5dd`. Press `/` to search and `n` to go to then next result. All these commands make writing code very easy.

Your hands are already at the keyboard, so why not improve your productivity with the commands?

Granted, if you are a soydev you may think "I already can use shortcuts". Fair, but can you use them over an ssh connection to a server? Can you use them in a router which only has busybox installed?

For my work I regularly have to use [Visual Studio](https://marketplace.visualstudio.com/items?itemName=JaredParMSFT.VsVim). Guess what? There's a vim plugin for it :grin:

![the vim editor](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ru2mf97w8dytmi7qlz33.png)

## Time matters

In life, every minute counts. It's not that life is to short, but that we waste to much of it. Vim is an admittedly strange thing. 

We all want to get more out of life. Vim can help you can more out of your coding work, by saving you some time with key strokes. It's in the box "high impact, high effort".

![high impact](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/30gvz7bbag07baluxve0.png)

It's a text editor that eschews all the standard buttons and commands in favor of keyboard shortcuts, and it has a complex learning curve and is very hard to use. 

But once you know how to use it, you can edit code super fast.


Vim has a few really great features that make it an editor I’d recommend to anyone who wants to be more productive. 

If you can get past the fact that it runs in the terminal, you may find that you can edit code a lot faster than with your existing editor.

Though it is different from more traditional software, you don’t need any special setup to get started with Vim. You just need to understand the basic commands. After that, you can learn more advanced stuff as you go.

## Does learning vim make sense?

Vim has been around for a long long time. vim was created by Bram Moolenaar in 1991 and was first released in 1992. That's like 30 years ago.

The word vim stands for “Vi IMproved” and the original vi was created by Bill Joy in 1976. Vi is very similar and even older than vim.

Most likely, vim will be around for many decades more. Because so many programmers (especially on Linux) use vim and  the terminal isn't going anywhere. 

Besides that the community puts vim or vim-mode in many programs including the web browser (vimium), programming IDEs like visual studio, visual studio code, phpstorm, pycharm etc.

![vim linux](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/i7jbq9dql77ajbux1orh.png)

Of course it's not the only editor, but learning it can save you quite some time. Vim is usually installed by default and can be installed on every operating system. In fact, it's even included by default on Mac OS X.

## Reasons to learn vim

There are a variety of reasons you should care about learning vim but here are my top reasons.

Reason 1: Learning how to use vim is the best way to get over your fear of the terminal.
Reason 2: Learning how to use vim will **change the way you code**.
Reason 3: Learning how to use vim will help you **build muscle memory** that works for you instead of against you.
Reason 4: It's already installed on Linux and Mac OS X by default, why not learn it?
Reason 5: **It will be around for a long long time**, long after the latest javascript framework (React, Vue etc) shows up.

Think about every time you’ve "hit enter and prayed" or "clicked through the options" when editing source files (or anything else that required input). 

It is because you didn’t have the necessary muscle memory or knowledge.

![vim vs emacs](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v5fmmpsgqofz5y6r9xdu.png)

No one cares if you use vim. Learning vim is not about what anyone else thinks. It doesn’t make you cool. It doesn’t make your code cleaner. It just makes your life a bit easier, and don't we all want that?