7 tips for using 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 to counterintuitive is it 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 increases 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, especially the I came that your improved version, and over time, until today, I find myself giving a : wq to sign out and save Firefox tabs!

How to use VIM I came (a contraction of Vi IMprov, in Portuguese "Vi Melhor") a clone of the text editor program saw to Bill Joy's Unix. J o saw, was written by Bram Moolenaar. O I came It is intended for use from either a command line interface or an isolated application on a graphical user interface.

It is free and open source software launched under a license that includes some charitable clauses, encouraging users who join the software to consider giving to Ugandan children.

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

  • Support for regular expressions in searches, with several standard length regular expression syntax;
  • Syntax highlighting (supporting over 500 languages);
  • Spell checker (version 7.0+);
  • Various colorschemes;
  • And hundreds of very peculiar features.

Among facilities and features, let's see 7 tips for using VIM as a PRO.

1 – Opening multiple files

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

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

vim -o file1.c file2.sh fileN.nnn

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

Or if you wish, you can also open multiple files horizontally using -O (MORE)

VIM Horizontal

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

split filename

2 – Getting the morning with Gvim

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

  • Document conversion;
  • Various themes and colors;
  • Easy setup of font family, font size and more;

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

Below are some screens that show the Gvim menu content.

GVIM

3 – Replace string words

Many text and IDE editors support Regular ExpressionsHowever, each has a limitation. But Vim has a custom support, friend, everything can be customized. There are even the customization of "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' to 'Vim', easier and faster than you think, just press ESC and write the command below, the g at the end for all occurrences, if you wanted a single change, just insert it:

The space after the saw was purposeful not to change also came

:% s/vi /Vim/g

4 – Key Mapping

You need to know that all keys are mappable in Vim, but as a basic tip, let's assume you're tired of typing : ggVG to select everything then you just have to 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 special for those who work with Software Development. Often the compiler / interpreter tells us the line number of the software execution or compilation error, and generally scrolling the mouse cursor to keep looking for the line, 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 in line 3 so you just type: ESC : 1370 you go straight to this line and back to the other lines, resolving the bugs, ops, sorry, word now faster and less stressfully Feature .

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

6 – PacVim

There are many people who take a long time to adapt to Vim and extract the best to accelerate their projects, so I recommend Pacvim a very cool game that teaches you, playing, how you adapt better to Vim, and use the keys: (, ), B, w, {, } to navigate documents more easily by skipping words, text, paragraphs, and so on. Pacvim

7 – Total Editor Customization

You can turn the I came It's the Editor you want, but your way: directory trees, word completion, Colors, brands, tags and even learn to Vim Programming Language!!! That's right, did you think Vim is the most used in the world just because you find it difficult? None of this, you can learn the Vimscript, an "vim programming language"where you can create functions, comments, custom files in the Vim configuration file. Vim Course For Beginners you will learn many cool tricks and tips from Vim and Vimscript, which you will soon be giving : wq to turn off your computer! .

See below the example image of my customization 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, enjoy and take two more courses at Promo Diolinux and learn I came and Extremely Advanced Shell Script: Creating Installers for Linux Distros, Creating Games, Animations and more!

Thanks!

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

_____________________________________________________________________________

See an error or would you like to add any suggestions to this article? Collaborate, click here.