⚡ Mosr used VI commands in Linux (VIM text Editor) 💎 Things we are going to learn: - Quick Navigation - Text Replacement - Find match - Jump to line number - Highlight match - Deleting lines - Enable Line number ################################################################## Join our telegram channel for more : https://t.me/LinuxClassesEFXTv ################################################################## 🔹 Replace Text in Vi/Vim 📝 ✅ Replace first occurrence in a line: :s/old_text/new_text/ ✅ Replace all occurrences in a line: :s/old_text/new_text/g ✅ Replace in the entire file: :%s/old_text/new_text/g ✅ Replace with confirmation: :%s/old_text/new_text/gc ✅ Replace in specific lines (e.g., 10-20): :10,20s/old_text/new_text/g ✅ Replace using regex (e.g., digits → NUMBER): :%s/[0-9]/NUMBER/g ✅ Replace text containing / using # as a delimiter: :%s#path/to/old#path/to/new#g ✅ Find a match /match ✅ Jump to next match n ✅ Jump to previous match N ✅ Enable Search Highlighting :set hlsearch 🔄 Disable Highlighting :nohlsearch ✅ Search and Highlight a Word /word ✅ Delete a Single Line 10d 🔄 Delete Multiple Lines from the Current Position 5dd 🔥 Delete All Lines :%d ✅ Temporarily Enable Line Numbers :set number ❌ Disable Line Numbers :set nonumber 🔄 Enable Relative Line Numbers (Useful for navigation) :set relativenumber 🚀 Make Line Numbers Permanent To enable line numbers every time Vim starts, add this to your nano ~/.vimrc set number 🏷️ Delete a Range of Lines 10,20d 📷 Delete the Current Line dd ⚡ Undo changes (deletion) [ESC]+u 🔁 Redo an Undo ctrl + r ✅ Copy a Specific Line (10th line) :10y ✅ Paste last copy (This pastes below the cursor, P above the cursor) [ESC] + p ✅ Copying the Current Line :yy ⚡ To copy lines 10 to 20, use :10,20y ⚡ Add 5 lines (- O 5 lines after existing line - o 5 lines before the existing line) ESC 5O ESC ESC 5o ESC 🔹 Jump to Specific Lines number 🔸 Jump to line 50: :50 🔸 Jump to first line: :1 🔸 Jump to last line: :$ 🔸 Open a file at line 100: vi +100 file.txt