Introduction
VIM, known for its speed, flexibility, and terminal efficiency, is foundational in modern Linux-based development and operations. Mastering VIM commands improves your productivity, enhances your troubleshooting capabilities, and allows seamless editing across remote and embedded systems.
In this article, we’ll explore what VIM is, break down its core modes, provide essential keyboard shortcuts, share best practices, and walk through real-world examples. Whether you're just starting or brushing up for RHCSA or DevOps work, this guide is structured to make learning fun and practical.
Table of Contents
- What is VIM?
- VIM Modes – The Heart of Navigation
- Best Practice: Enable Line Numbers
- Essential VIM Shortcuts (Command Mode)
- Fun Learning Challenge: VIM Practice Lab
- VIM Tips & Hidden Gems
- Conclusion
What is VIM?
VIM stands for Vi IMproved. It is a highly configurable text editor built to enable efficient text editing and scripting from the command line. Originally developed as an enhancement to the vi
editor, VIM has become one of the most widely used tools for editing files within terminal-based environments across Unix, Linux, and even Windows (via WSL or Git Bash).
Key Features
- Syntax highlighting for many programming languages
- Persistent undo history
- Support for plugins and themes
- Extremely lightweight and fast
- Operates completely within the terminal (no GUI required)
VIM is essential in environments where GUI tools are inaccessible — such as remote servers, containers, embedded devices, and CI/CD pipelines.
VIM Modes – The Heart of Navigation
There are three primary modes in VIM. Each one serves a unique purpose:
1. Command Mode
This is the default mode when you open a file.
vim filename.txt
- You can navigate, delete, copy, and paste in this mode.
- Press
i
to switch to Insert Mode.
2. Insert Mode
- This mode allows you to type, edit, and make changes.
- Once you’re done, press
ESC
to return to Command Mode.
3. Extended Mode
Accessed by pressing
:
from Command Mode.You can now issue commands such as:
:wq
→ Save and quit:q!
→ Quit without saving
🎯 Fun Tip: Think of Command Mode as "looking at the paper," Insert Mode as "writing on it," and Extended Mode as "deciding what to do with it."
Best Practice: Enable Line Numbers
Line numbers help you track changes, navigate efficiently, and debug configurations.
Always enable them when working with long scripts or configuration files.
- Enable line numbers:
:se nu
- Disable line numbers:
:se nonu
✨ Essential VIM Shortcuts (Command Mode)
🔄 Copy Commands
-
yy
– Copy current line -
nyy
– Copy nextn
lines -
yw
– Copy current word
❌ Delete Commands
-
dd
– Delete current line -
ndd
– Delete nextn
lines -
dw
– Delete current word
🚀 Navigation Commands
-
gg
– Go to the top of the file -
G
– Go to the bottom of the file -
ngg
ornG
– Go to line numbern
📌 Other Shortcuts
-
p
– Paste -
u
– Undo -
Ctrl + r
– Redo
🧪 Fun Learning Challenge: VIM Practice Lab
Try creating a file and walk through this challenge:
vim demo.txt
- Enable line numbers
- Insert 5 lines of text
- Copy the second line
- Paste it below
- Delete the last two lines
- Save and quit
✅ Repeat this daily for 5 minutes to build muscle memory and become fluent in VIM navigation!
VIM Tips & Hidden Gems
1. Qucikly switch Between Files
- Open multiple files:
vim filename1.txt filename2.txt
- Switch between files:
:n #next file
:prev #previous file
2. Search in VIM
- Use
/
or?
to search forward or backward.
/wordtosearch
- Use
n
andN
to jump to the next or previous match.
3. Replace Words
- Replace all occurrences of a word in the file using substitution commands.
:%s/apple/android/g
4. Highlight Word
- Press
*
on a word to highlight all its matches in the file.
5. Split Screen Editing
- Use
:split
or:vsplit
to open files side-by-side.
- Horizontal split:
:split otherfile.txt
- Vertical split:
:vsplit otherfile.txt
- Use
Ctrl + w
and arrow keys (orhjkl
) to move between splits.
6. Save As
- Use the
:w
command followed by a new filename to save the file under a different name.
:w newfilename.txt
7. Jump to Matching Brackets
- Place the cursor on a bracket or brace and press
%
.
8. Access Built-in Help
- Use
:help
followed by any command name for instant documentation.
:help
:help <command>
Conclusion
VIM may seem overwhelming at first, but with regular use, it becomes a powerful ally in your terminal toolkit. Whether you're editing scripts, updating configuration files, or writing documentation—VIM's efficiency and depth can truly set you apart.
Let’s make VIM second nature — one keystroke at a time. 🚀
📣 Follow me on LinkedIn for more real-world Linux and DevOps guides!
Top comments (0)