7 tips for you to use VIM as a PRO


The first time I used the saw, I found the most ridiculous thing in the world ? , I thought to myself, as an editor so counterintuitive so successful? But I had to learn it, because several times the software tests were on the “dry” terminal, with nothing, and changes were only possible via the saw, because in a test environment nothing is increased that will change the behavior of a software in its standard environment.

I realized that this was the reality of several people, each in a different situation, but all with the same mission: to use the saw. Over time I tried to learn it, mainly the I came which is its improved version, and over time, until today, I find myself giving a : wq to exit and save the Firefox tabs!?

I came (a contraction of Vi IMproved, in Portuguese “Vi Melhorado”) is a clone of the text editor program saw for Bill Joy’s Unix. The saw, was written by Bram Moolenaar. THE I came it is intended for use from both a command line interface and an isolated application in a graphical user interface.

It is free and open source software and is released under a license that includes some charity clauses, encouraging users who join the software to consider donating to children in Uganda.

Among the many characteristics of Vim, we can mention some highlights.m

  • Support for regular expressions in searches, with several extensions to the standard syntax of regular expressions;
  • Syntax highlighting (with support for more than 500 languages);
  • Spell checker (version 7.0+);
  • Various color themes (colorschemes);
  • And hundreds of very peculiar characteristics.

Among facilities and features, we’ll see 7 tips for you to use VIM as a PRO.

1 – Opening multiple files

If you want to work on a file and at the same time view the contents of other files, then there is the possibility to open them simultaneously with a single view.

You can open both vertically using the parameter -The (tiny) using the command:

vim -o arquivo1.c arquivo2.sh arquivoN.nnn

The output will be similar to the content of the image below:

Vertical VIM

Horizontal VIM

Not to mention that you can open them later using the command:

split nome-do-arquivo

2 – Taking the morning with Gvim

If you want to adapt quickly to Vim, it is interesting to start using Gvim, for example. Gvim is Vim with a graphical interface, that is, it works all commands equally, including the settings, however it has its own characteristics, similar to those of conventional editors. Between them:

  • Document conversion;
  • Varied themes and colors;
  • Easy font family configuration, font size and more;

In addition, each menu has the possibility to execute it via command, informing you of the command. That is, you learn using.

See below some screens that show Gvim menu content.


3 – Substitution of words with character strings

Many text editors and IDEs have support for Regular Expressions, however, each has a limitation. But Vim has a customized support, it is a friend, everything can be customized. There is even the customization of the “hands on the wheel”, to find and replace them there are several ways, however, I will give you the simplest tip. Suppose we want to change all the words ‘vi’ for ‘Vim’, it’s easier and faster than you think, just press ESC and write the command below, the g at the end it is for all occurrences, if you wanted a single exchange, just do not insert it:

The space after the saw was purposeful so as not to change the vim

:% s/vi /Vim/g

4 – Key mapping

It is necessary to know that all keys are mappable in Vim, but as a basic tip, let’s assume that you are tired of typing : ggVG to select everything, then just map the key F12 , just give ESC and enter the command below:

:map  ggVG?

From now on every time you are in NORMAL mode, just press F12 and you will select everything! ?

5 – Fast navigation

This is special for anyone working with Software Development. Often the compiler / interpreter informs us of the line number of the error of the execution or compilation of the software and generally rolling the mouse cursor to keep looking for the line, is a real waste of time, in Vim you can easily browse the file. For example, the compiler told you that errors were found in the lines: 1370, 846 and on the line 3 , so you just need to type: ESC : 1370 you go directly to that line and back to the other lines, solving bugs, ops, sorry, the word is now faster and less stressful Feature ?.

Ah! I was almost forgetting myself !! To go to the first line just type: gg and for the last line G ?.

6 – PacVim

There are a lot of people who take time to adapt to Vim and extract the best from it to speed up their projects, for this I recommend Pacvim a very cool game that teaches you, playing, how you adapt best to vim, and use the keys: [, ], B, w, {, } to navigate documents more easily, skipping words, texts, paragraphs and so on.

To find out how to install and use it, check their GitHub: https://github.com/jmoon018/PacVim, just be careful not to get addicted! ?


7 – Full Editor Customization

You can transform the I came in the Editor you want, but in your own way: directory trees, auto-complete of words, Colors, brands, tags and even learn to Vim Programming Language!!! That’s right, did you think that Vim is the most used in the world just because you consider it difficult? None of this, you can learn the Vimscript, is «vim programming language”, Where you can create functions, comments, customized files in the Vim configuration file. Vim Course for Beginners you will learn several cool tricks and tips from Vim and Vimscript, that in a short time you will be giving : wq to shut down your computer! .

See below the example image of my customization by writing this article in Markdown for Diolinux, with plugins and auto complete words.

Writing the article in VIM

If you wish to purchase the Course, take advantage and take two more courses at Diolinux Promotion and learn I came and Extremely Advanced Shell Script: Creating Installers for Linux Distros, Creating Games, Animations and much more!


Article produced in conjunction with Marcos Oliveira, from Terminal Root.