Introduction
If Nano is "Notepad," then Vim is the cockpit of a fighter jet.
It is powerful, fast, and available universally. But it is also famous for being confusing to beginners.
Why use it? Once you learn the "secret handshakes" (shortcuts), you can edit text faster than you can think.
Vim has a long history and a strong reputation in Unix and Linux culture. People keep using it not because it is friendly at first glance, but because its keyboard-driven editing model can become extremely efficient once the basics click.
In this lab, you will learn the absolute basics: how to open it, type something, and—most importantly—how to exit.
Open File
Let's start by opening a file. We have prepared one for you called welcome.txt.
Run this command:
vim welcome.txt
Welcome to Vim.
Don't Panic:
You might try to type immediately, but nothing will happen.
This is because Vim starts in Normal Mode. In this mode, your keyboard keys are commands. Pressing d doesn't type "d"; it might delete something!
This "modes" idea is the main reason Vim feels strange to beginners. Most editors assume the keyboard is always for typing text. Vim separates typing from commanding, which creates a learning curve but also enables very fast editing once you understand the pattern.
To type text, we must switch modes.
Insert Text (Insert Mode)
To type, we must enter Insert Mode.
Press the letter i.
Look at the bottom left corner. You should see: -- INSERT --
Now Vim behaves like a normal text editor. You can type freely.
It helps to think of Insert Mode as temporary. You enter it when you need to write text, then return to Normal Mode when you want to navigate or perform editing commands.
Return to Normal Mode (Esc)
Now add a new line to the file.
Use arrow keys to move to the end, press Enter, and type:
Hello LabEx
Great, you've added text. Now, stop!
To save or exit, you must go back to Normal Mode.
Press the Esc key.
The -- INSERT -- label will disappear. You are now back in command mode, where keys are tools.
Rule of thumb: If you aren't actively typing, hit Esc.
That advice is famous among Vim users for a reason. Esc is the quick way back to a safe, predictable command state.
Delete Line (dd)
Let's use a "Normal Mode" power move to delete a line.
- Ensure you are in Normal Mode (press
Esc). - Move your cursor to the line:
This is a line that you will delete later. - Press
dtwice quickly:dd.
Zap! The line is gone. dd stands for "Delete Line".
This step reveals why Vim is considered powerful. Short key sequences can operate on text structurally, not just character by character.
Save and Exit (:wq)
Now, the most famous question: "How do I exit Vim?"
We use the colon : commands.
- Ensure you are in Normal Mode (Press
Esc). - Type
:wq.w: Write (save).q: Quit (exit).
- You should see
:wqat the bottom left. - Press Enter.
Vim will save and close. You are back in the shell!
Colon commands like :wq are part of Vim's command-line interface inside the editor itself. In other words, Vim contains its own mini command system in addition to its editing modes.
Summary
You have survived your first trip into Vim.
vim filename: Open the cockpit.i: Insert Mode (start typing).Esc: Normal Mode (stop typing, ready for commands).dd: Delete line.:wq: Write and Quit.
It takes muscle memory, but mastering Vim makes you a true Linux power user.



