You shouldn't be so scary about Vim

Yago Azedias
6 min readApr 12, 2019

How can the sky be the limit when there’s footprints on the moon?— Logic

Main picture (Title over picture says: "When you try to exist vim". King t’chala says: “we don’t do that here” when banner tries to bow for him in avengers infinity war)

Vim is an excellent tool for you to have in your tool-set as a software developer. Just like the most part of the programmers I only have head about Vim, but never actually got the interest to use it for real. Until I be surrounded by other people that have been using it for a while. In their opinion, programming in any other IDE or text editor you feel yourself like a turtle. Thinking about that I tried it. And now I have a humble opinion about the tool that I would like to share with you!

Topic 1: It is easier than you think

Some software engineers think that Vim is a hard thing to learn, I do not think like that. Mainly for software developers that already learned things harder than a text editor, like: Calculus, Math, Physics, etc. In fact learn to use an IntelliJ, Eclipse or Atom in your total capacity with all available tools can be as hard as the Vim editor. The first thing that you have to deal with is the paradigm. Vim has his own way to edit text, once you have accepted it you can finally use it for real.

Vim wants you to keep the hands on the keyboard, because it is everything that matters. You do not have to use your mouse in order to edit a text, it is completely unnecessary and it also decreases you productivity.

Topic 2: It is very funny

As a software developer I feel happiness when I’ve been creating things and when I’ve been doing it in the best way, that is called The Joys of The Craft. Vim in some cases is the best text editor to use, of course if you’re coding in Java or .NET you’ll rather use a IDE focused on those environments, in order to turn your work easier. But in the rest of others languages Vim going to save you a lot of effort and typing time. We’re going to see that using Vim you earn some advantages like: navigate between methods and their definitions is fast and easy, reach some part of your code using relative numbers, a lot of plugins that help you to take care of your code and even more.

Let’s get started: Installation

Vim means “Vi IMproved”. Functionally, vim is almost a proper super set of vi. Therefore, everything that is in vi is available in vim. And the name “vi” is derived from the shortest unambiguous abbreviation for the ex command visual, which switches the ex line editor to visual mode. Install vim is a relative simple work, if you are using a Debian based Linux you can just install it with apt-get:

sudo apt-get install vim

After that I’m going to ask you to complete the vimtutor guide to introduce yourself to vim, just like any Go Lang beginner must past through the Go Tour and any Ruby on Rails developer have to complete the "15 minutes blog". That way you will be able to change your approach of writing code and be able to navigate to your code file using the letters: H J K L

Vimtutor example

Let’s get started: Improving Vim

Vim is a powerful weapon, but it doesn't means that it can’t be upgraded. Just like any text editor, Vim has a huge amount of fans that create and maintain plugins. You can configure the plugins by hand if you want, but we have a project made for Rafael Martins that turns our lives easier in order to setup our Vim tool set. The repository has a lot of plugins that I’m going to explain later, but first let’s setup it!

Make sure that you have python3 and pip3 installed in your machine with the following commands:

sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt-get update
sudo apt-get -y install python3.6
sudo apt-get -y install python3-pip

Then install neovim:

pip3 install neovim

After that you can clone the repository and execute a make command to install the rest:

git clone https://github.com/yagoazedias/vim && cd vim && make
Terminal video with steps for vim configuration

Now that we have setup our Vim tooling, let’s take a look at what are the vantages that we got.

Vim Plugins: Nerdtree

Nerdtree is a file/folder navigator, just like the normal tree panel in others text editors. But here you can easily navigate in your files using the H J K L letters and open buffers in the vertical or horizontal perspective. To open it just press <F2> and it will automatic open and already focused

You can also use Nerdtree to create and delete folders, using the menu that can be open pressing the m key. If you want to know more, just press ? for help.

Nerdtree example

Vim Plugins: TagBar

Tagbar is a Vim plugin that provides an easy way to browse the tags of the current file and get an overview of its structure. It does that by creating a sidebar that displays the ctags-generated tags of the current file, ordered by their scope.

You can open Tagbar pressing <F3> it won’t be focused, you have to press <CTRL> + w to shift to tagbat’s buffer or use <CTRL> + l that will focus on the right side buffer.

Tagbar example

Vim Plugins: ctrlp

It’s a file finder for vim, just like VScode when you press <ctrl> + p and it going to allow you to search the project files.

As you can see in the example gif, you are able to open the files in a vertical buffer, horizontal buffer, or even in a new tab. It’s really useful tool

ctrlp plugin example

Vim Plugins: vim-move

Some programmers like the feature to move a code block or a line simply selecting it and pressing the down / up key. With vim we also have an alternative for that.

Vim Plugins: vim-codefmt

It is a simple formatter for vim, in our vim setup we configured it to run each time that you write in a buffer

Code format example

Vim Plugins: vim-esearch

I’ll probably would like to search in your entire project for specific word or sentence. Vim turns it easy with esearch plugin. Just hit our <Leader> key witch is , (on our setup, for another vim configuration it may be a different one) and them ff :

Vim Plugins: vim-colorschemes

And for the last but not least, you also can shift the default color scheme for you vim editor, I personally like a lot of onedark colorscheme, but there are other alternatives as well:

Colorscheme plugin

More content

Vim has a lot of fans and developers that uses it in their daily routine, that way we have a lot of content and help on the internet for those who want to go deep in the vim community. The is an awesome-list, which is an excellent place to get started. Some extra information you can please comment bellow and don’t forget the claps if you like the content :)

--

--