This part of my Linux journey focuses on editing files using Vim, one of the most widely used terminal editors in Linux. As a beginner, learning Vim is essential because many configuration files and scripts are edited directly in the terminal, especially when working as a SysAdmin or aspiring Site Reliability Engineer.
Vim (Vi Improved) is a terminal-based text editor available on almost all Linux systems.
It is commonly used by system administrators to edit configuration files, scripts, and system settings.
Opening a File with Vim
vim filename.txt
Example:
vim mynotes.text
Vim has 3 main modes;
Normal Mode
- The default mode when vim opens.
- Used for navigation and commands.
- You cannot type text in this mode.
Insert Mode
- Used to write and edit text.
- Press
ito enter insert mode.
Command Mode
- Used to save, quit and run commands.
- Press
Escthen type:to enter command mode.
Writing text in Vim
vim filename.txt - To create a file or open if there's an existing file.
Press i to insert mode or to edit your file.
Saving and Exiting Vim
After editing, Press Esc to enter to Normal Mode.
Then;
:wq or Shift + ZZ - to Save and exit.
:w - to Save without exiting.
:q! - to Exit without saving.
:q - to Exit (only if no changes happen, or else vim will show an error.
Basic Navigation in Vim
h - left
j - down
k - up
l - right
Deleting Text
In Normal Mode
x - Used delete one character.
dd - Used delete one line.
d$ - Used delete to the end of the line.
dw - Used delete word.
u - Used to undo last action.
Vim Apprentice user Level
p - Paste Command
After deleting with dd, you can paste it wiht p to the line that you lke to paste it.
r - To replace a letter.
Press r followed by the letter or you want to replace.
ce - To replace a single word.
c$ - To replace the entire line.
In this part of my Linux journey, I learned:
- What Vim is and why it’s important
- The three Vim modes (Normal, Insert, Command)
- How to write, save, and exit files
- Basic navigation and text deletion
To Be Continued…
Tomorrow, I will continue my Vim learning journey to cover:
- Vim Experienced User Level
- Vim Veteran User Level
- Vim Expert User Level
This will include more advanced editing, searching, and productivity features that every Linux power user should know.
Top comments (0)