Top 5 reasons why you should be using vim

I absolutely love vim. For me and many more programmers like me, it is the best text editor in the world. Like Emacs, it is a power tool that is designed to utilize the keyboard to its fullest. I have become so used to vim that it is hard for me to use any other tools that lack its features. As such, I have installed it in my browser, outlook and even Visual Studio where I do most of my work. Even though it is not as easy as other text editors, I encourage everyone to start learning vim and wield its amazing power.

vim

With that said, here are the top 5 reasons why you should consider using vim.

1. Vim runs anywhere

Vi/Vim is available on all Linux distributions and Unix based distributions (macOS). It can also be installed on Windows. No matter what platform you wander into, some form of vi will already be available for you to use. Some large companies may require approval to install another package and may take days to undergo the change. For this reason, you should start using the ubiquitous vi/vim.

Not only that, vim emulation can also run on many popular softwares like Microsoft Office, Google Chrome, Firefox, etc. As mentioned before, I am using vim emulation on my Chrome, Outlook, and Visual Studio.


2. Vim is powerful

Normal text editors just cannot compare to the power of vim. You can use motions and combination of composable commands to perform complicated operations quickly and easily. Some of the other powerful features of vim include macros, registers, text objects, searching, filtering, global substitution, command repetition, auto-completion.

In nano, what would you do to delete a specific line from a file? Probably use the arrow keys to navigate to it and hold delete until the whole line is gone. In vim, you can scroll to it with 5j (5 lines down), then press dd to delete the entire line.

Additionally, vim is also a modal editor: it has different modes for inserting text and manipulating text. Programmers spend a lot of time reading, navigating, and making small edits. As such, vim is designed to support this idea.

Modes in Vim

  • Normal: for moving and making edits
  • Insert: for inserting text
  • Replace: for replacing text
  • Visual: for selecting blocks of text
  • Command: for running a command

3. Vim uses less memory

As vim works on the terminal, you do not need to have a graphical interface running to work on it. Graphical interfaces consume a sizeable memory and running vim without them puts less load on the system.

Besides that, vim is also extremely fast and lightweight, capable of working on a system with limited resources. I have used it comfortably on a 512 MB Puppy Linux virtual machine.

Opening large files is also easier on it than other text editors. I once had to edit the contents of a 2 GB csv file. Opening it on notepad caused my system to hang. However, I was able to easily open it on my vim and perform some edits.


4. Vim makes you more efficient

Using vim, you can make full use of the keyboard without ever touching the mouse. This avoids the constant switching back and forth between them, improving your efficiency. Using vim's powerful features of commands, motions, and text objects, you can perform complex operations with just a few keystrokes. Learn more about them here.

As a C# programmer, I constantly need to edit the implementation of a function. Using vim, I can simply do this by pressing the keys ci{. Here the first character c is a command that means change. The i{ is a text object meaning everything inside {. Using this combination, vim deletes all the contents between the curly brackets and switches to insert mode, so that I can starting writing code.

Vim is also used by most of the Linux system administrators in the world due to its efficiency and availability. Since Linux servers do not have a graphical interface installed by default, it is more common to use vim to modify the contents of any files on them by sshing into it.

I once saw a colleague of mine making some tedious changes to a config file on a Linux server by downloading the file to his local system, editing the file, and then uploading it back to the server. This is an extremely inefficient process, and everyone should avoid doing this. If he had used vim, he could have made the changes more quickly and efficiently.


5. Vim is highly customizable and extensible

With a vibrant community and an extensive plugin system, vim is one of the most customizable and extensible text editors. Essential features that developers require like intellisense, code navigation, fuzzy searching, git integration, syntax highlighting, linting are all available using plugins.

You want a git helper? Vim has vim-fugitive. You want a different theme? There are hundreds of themes available in vimcolors and awesome-vim-colors.

In addition, there are also some plugins that make it behave like an IDE: coc.nvim for intellisense, fzf.vim for fuzzy searching, neomake for linting, and many more.

There are several plugin managers (vim-plug, vundle, dein.vim, etc.) to choose from today.

You can also use vimscript to customize your vim or create your own plugins. Also, the customization you make are portable. So, if you customize it in one system, it can be easily ported to another one. Check out my vim customization here.

On top of that, vim also has a great community. It has a reddit page, twitter accounts, stackexchange, and more. A strong community guarantees continuous development and bug fixes, which implies even more community plugins, tutorials, and extensibility.


Lastly, vim is fun to learn. You will realize it once you start using it. As you get good at it, you will be able to do amazing things on it.

Have I convinced you to start learning vim? If yes, remember it is not as simple as the others. But once you get over the learning curve, it is truly a game-changer. Here, these guides should help you get started:

Kshitiz

Kshitiz Shakya

Principal Software Engineer at GrowByData