Vim Basics Tutorial
A basic tutorial with the minimum commands you need to know to use Vim as your terminal text editor.

I wrote this post in Spanish in 2022 and adapted it to English in 2026.
This is a short tutorial on the most basic Vim commands. It's not advanced. It's so you know how to get around, and from here you can dig in on your own and become a Vim Jedi.
Basic Vim (Vi IMproved) Commands #
Create a file
$ vim file_name.extension
# Example:
$ vim random.py
By default you can't type; you move around with:
J: up
K: down
H: right
L: left
If you want to type, you have to enter -- INSERT -- mode, and you do that by pressing i.
Leave -- INSERT -- mode
Press the Esc key.
Quit the editor
:q
Save and quit
:wq
To skip any questions, add a ! at the end, for example to quit the editor:
:wq!
Show line numbers
:set nu
Hide line numbers:
:set nu!
Cut a line
dd
Paste a cut line
p
Copy a line
yy
Create a new line
o
(The letter o. It automatically enters -- INSERT -- mode.)
Cut several lines
d[number]d
d3d
(d3d cuts 3 lines in a row.)
Copy several lines
y[number]y
y3y
(y3y copies 3 lines in a row.)
Undo a change
u
uuu
(uuu undoes the last 3 changes.)
Redo an undone change
Ctrl + r
Enter visual mode in Vim
v
Search for text in the file in Vim
/text
Then press Enter. It takes you to the first match; to go to the next one press n, and to go to the previous one press Shift + n.
Go to the start of the file in Vim
gg
Go to the end of the file in Vim
Shift + g
Go to the start of the line in Vim
0 (zero) or the Home key.
Go to the end of the line in Vim
$ or the End key.
Save a file with whatever name you like in Vim
:w foo.txt
This creates a file named foo with the .txt extension.
If you save a file that already existed under a different name, Vim will create a new "copy" file if you didn't change anything, and a "new" one if you made changes.
Indent multiple lines in Vim
:start_line,end_line>
where:
- start_line is the first line
- end_line is the last line
- > is the number of indents
example:
1 text
2 text
3 text
4 text
5 text
:2,3>>
Result:
1 text
2 text
3 text
4 text
5 text
Open a folder with Vim
$ vim /path_to_folder/
$ vim . # opens the current folder
Go back to the folder after opening a file
:#b


