VIM is one of the most powerful text editors available in Linux and Unix systems. It can be intimidating for beginners, but once you get the basics, you will realize how fast and efficient it is. This tutorial will walk you through VIM for beginners with simple examples so you can start using it confidently.
What is VIM?
VIM (Vi Improved) is an advanced version of the classic Vi editor. It is:
- Pre installed on most Linux systems
- Lightweight and super fast
- Great for developers, sysadmins and power users
VIM is keyboard driven, meaning you can do everything without a mouse. This makes editing faster once you learn the commands.
How to Open and Exit VIM
To open a file in VIM:
vim filename.txt
If the file does not exist, VIM will create it.
To exit VIM:
- Press
Esc
(to make sure you’re not in insert mode) -
Type one of the following:
-
:q
→ Quit -
:q!
→ Quit without saving -
:wq
→ Save and quit -
:w
→ Save without quitting
-
VIM Modes Explained
VIM works in different modes:
- Normal Mode – Default mode (for navigation and commands)
-
Insert Mode – For typing text (press
i
to enter) -
Command Mode – For running commands (press
:
)
👉 Quick switch:
-
i
→ Insert mode -
Esc
→ Back to Normal mode -
:
→ Command mode
Basic Navigation in VIM
In Normal Mode:
-
h
→ Move left -
l
→ Move right -
k
→ Move up -
j
→ Move down
👉 Tip: You can also use arrow keys, but learning hjkl
will make you faster.
Editing Text in VIM
Insert Text
-
i
→ Insert before cursor -
a
→ Append after cursor -
o
→ Open a new line below
Delete Text
-
x
→ Delete one character -
dd
→ Delete a whole line -
dw
→ Delete a word
Copy & Paste
-
yy
→ Copy a line (yank) -
p
→ Paste after cursor
Undo & Redo
-
u
→ Undo -
Ctrl + r
→ Redo
Searching and Replacing
Search
To search for a word:
/word
Press n
for next match, N
for previous.
Replace
To replace "old" with "new":
:%s/old/new/g
Example Workflow in VIM
- Open a file:
vim hello.txt
- Press
i
and type:
Hello VIM!
This is my first file.
- Press
Esc
- Save and exit:
:wq
Pro Tips for Beginners
- Use
vimtutor
command in terminal for practice - Start with basic commands before advanced features
- Don’t worry about speed at first accuracy matters
Conclusion
VIM may look difficult at the beginning, but with practice, you will become faster and more efficient than using any graphical editor. Start with small steps, practice the basics and soon you will love working with VIM.
👉 Try opening a file right now and test these commands. The more you practice, the easier VIM becomes.
Did this tutorial help you? Share your thoughts in the comments on dev.to.
Top comments (2)
Nice Article. It is very helpful to introduce and guide developers to use VIM or vi once a while. Those who work on Server side and those on mac systems find it convinient to use. It is the same vi basics since last 30+ years I am using. There are many more features, difficult to get outside of it. A closer match these days is notepad++
Just a few more here.
to add/replace text at the beginning of the line
:%s/^/new text/
to add/replace text at the end of the line
:%s/$/new text/
For navigation, if you need to find the matching brackets in a json text, use key
%
to get to first line
1G
, to get to last lineG
, to get character of the line$
..And so on...
Thank you for your lovely words and the great overview.