
Vim is not your normal text editor. It is designed to make use of the keyboard keys to maximize editing efficiency. This characteristic, however, makes it hard to handle at first. This article aims to teach you how to edit text using Vim.
Why Vim?
Vim is like having cheat codes for text editing. Although many people find it counter intuitive at first, Vim features map directly to what we as editors want to achieve, like:
- Change the next word with a new idea (type
cw
for “change word”) - Delete 3 lines (type
3D
). - Append new text at the end of the line (type
A
).
Vim provides bindings for those typical use cases and more, so as you can see, Vim is actually straightforward and pretty much intuitive once you catch the idea.
Open/Close Vim
Opening a file with Vim is trivial, on your terminal just run:
vim file.txt
However, often the hardest part is to close the file.
Enter normal mode (Esc) and then type :x
(colon then x). The press enter and it will first save the contents of the file and then exit from it. Notice that we entered the Command Mode with the colon key, and then wrote x
. There are other useful commands when it comes to closing and saving a file:
:w
Save the current contents of the file.:q
Closes the file if no changes were made.:wq
Write (save) and close the file.:x
Shortcut for:wq
:q!
Close the file without saving it, even if changes were made (changes are lost)
Vim Modes

Your normal text editor works in a single mode: Insert Mode. That is why a character is inserted when you type it in your keyword.
However Vim provides multiple modes which makes it so powerful but so annoying at first:
- Normal Mode
- Vim’s default mode.
- In this mode, each key represents an operation (for instance,
r
for replace). - This mode is selected by pressing the
Esc
key.
- Insert Mode
- This mode works as your typical text editor (pressing keys inserts those characters into the file).
- Select this mode by pressing the
i
key while in Normal Mode.
- Command Mode & Visual Mode
- Not of interest for this survival guide.
Navigation Basics
In normal mode, there are plenty of options to navigate the content of your file:
- Arrow keys (↑ ↓ → ←)
- h, j, k, l keys
h
: leftj
: downk
: upl
: right
The arrow keys are easier and can be used in insert mode too, however hjkl are quicker since you don’t need to leave the main keyboard row. If you are a gamer, you already had to get used to wasd, so why not hjkl? 😉
There are other movements out of the scope of this article, like w (to move through words instead of characters).
Inserting Text
The most common use of a text editor is to insert, delete and modify text. That will be our starting point to survive Vim. As discussed, we need to enter Insert Mode. The following gif shows how to add text to a shopping list by getting into insert mode.

While in insert mode, you can do pretty much everything you do in your current text editor, like delete characters, move around with the arrow keys, and so on.
Copy, Delete and Paste Lines
While in normal mode (Esc):
Y
oryy
: yanks (copies) the current line.p
: pastes the copied line below.P
: pastes the copied line above.D
ordd
: deletes the current line (it also yanks the line so we can paste it later)
We can combine those with digits to run the operation multiple times. For instance: 3D
or 3dd
deletes 3 lines.
Let’s use what we learned to refactor our shopping list (say we figured the last 3 items should have more priority so we want to move them to the top of the list)
