The latest beginner’s guide to Vim

In our previous post on Vim, we talked about some neat tips and tricks suitable for more advanced users. In this article, we will talk about how to get started with Vim, so this tutorial is mainly intended for absolute beginners. Usually, when a newbie opens a document with Vim for the first time, the user experience is nothing short of frustration, since the user has no idea how to do anything, and what exiting the program involves as well. So you are frustrated, “What is this ?! I go back to nano, it doesn’t work! “- How desperate you keep pressing CTRL-C or ESC in an attempt to exit the editor, but end up closing and eventually reopening the PuTTY terminal.

If you use Linux-like systems all the time, learning Vim is like an investment. It takes a long time to get started, but the more you use it, the better and more productive you will be.

So let’s get started.

First, you may not have Vim on your server. So let’s install Vim first:

How to install Vim

It’s pretty easy and straightforward. Just run the following commands based on the distribution you are using.

For CentOS

                      yum install vim

For Ubuntu

                      apt-get update && apt-get install vim

For Arch Linux

                      pacman -S vim

General – Three Vim Modes

Before going any further, you need to first understand how Vim works. In a nutshell, Vim has three main modes of operation.

Command mode – where you can pass Vim commands to manipulate the document. You searched for text, copied / pasted parts of it. Find and replace text based on a template and more. There are virtually no restrictions on what can be achieved in this mode.

Insert mode – This is where text writing can be done.

Visual mode – It’s like a submode in command mode where you can select text.


This is the default mode, and the one when you find yourself in when you open a file with Vim. In this mode, you cannot type, but you can pass Vim commands. You can scroll through the document using the arrow keys and go up / down using the Page Up and Page Down keys. By passing commands to Vim, you have the ability to quickly manipulate the file being edited in a way that no other text editor offers.

There are several ways you can pipe a command to Vim in this mode. For now, you should only know the most basic ones:

i – Puts you into text input mode – where you can enter just like in any other editor; At the same time with the key ESC you can exit insert mode;

:w – Save / write changes to disk;

:w! – Save, but do not ask for confirmation; (means quick!)

:q – Quit Vim if no changes have been made;

:q! – Exit Vim and discard changes;

Some commands (those that are compatible can be combined together).

:wq! – Save changes and exit;

The last two teams :q! and :wq!  which you will most often use.


As the name suggests, this is the mode in which it does print.

Using from command mode, you can go into insert mode, do what you like and make changes, and then exit back to command mode with the ESC key.


In this mode, you can select text. You can think of this mode as a submode of the command line mode. You can select either entire blocks of text or select only one part of it. While in command line mode, there are three types of VISUAL mode that you can enter.

v – Includes the easiest visual mode. Being in the command mode, the cursor is anywhere in the text and press V. You will see that in the lower left corner of the terminal the status will change to -- VISUAL -- … Now you can move the cursor with the arrow keys and select parts of the text.

V – This is the VISUAL LINE mode -. Use this mode when you need to select entire lines.

CTRL-V – This is the mode -VISUAL BLOCK- … Use this mode to select blocks of text by freely moving the cursor around.

Now that we know the three main modes, we can extract some useful commands. They work in command line mode but are also very useful when used visually. That is the exact reason why we mention these commands here.

0 – Place the cursor at the beginning of the line;

$ – Will position the cursor to the end of the line;

o – Will enter the Insert mode and a new line for writing;

y – Copy (y stands for jerk);

yy – Copy the entire line;

p – Paste;

P – Paste over cursor;

d – To cut;

dd – Cut the entire line;

x – Just delete. Usually will delete the selected character or a piece of text selected with v … However, we found that in visual mode there is no difference between and x.

u – Cancel;

CTRL-R – Repeat;

:set number  – Enable or disable line numbering. This does not affect the document, this is just for reference;

:set number! – Disable line numbering;

Where line numbering is on you can quickly jump to the line number where you need it:

:10 – Go to line 10

:5 – Go to line 5

.. etc.

Tips for practicing

Everything above is just a quick summary of Vim’s functionality.

How to practice? Open a new document vim lorem.ipsum.txt and then go to generator Lorem ipsum and generate some paragraphs of text. Paste these points into your document and start practicing. While working on systems, the practice of editing files with Vim. Over time, you will only get better. As we said earlier, learning Vim isn’t just a waste of time, it’s an investment. This will increase your productivity and functionality. Once you learn its functions, you will be slowly throwing away all other text editors.

Once you get used to these basic commands, you can check out our other article for more advanced file manipulation tricks.

Related Posts