1️⃣ The Most Important Concept in vi vi has 3 modes. Mode Purpose Normal Mode Navigation & commands Insert Mode Typing text Command Mode Save, quit, search You start in Normal mode. Press: i ➡️ enter Insert mode Press: ESC ➡️ return to Normal mode
2️⃣ The Most Important Commands (Must Know) These are life-saving commands. Command Meaning :w save :q quit :wq save + quit :q! quit without saving Example: ESC :wq
3️⃣ Super Fast Cursor Movement ⚡ Instead of arrow keys. Key Action h left l right j down k up Example: j j j Move 3 lines down.
4️⃣ Jump Faster (Huge Productivity Boost) Command Meaning 0 start of line $ end of line gg go to start of file G go to end of file :25 go to line 25 Example: gg ➡️ start of file
5️⃣ Delete Like a Ninja 🥷 Command Action x delete character dd delete line 5dd delete 5 lines D delete till end of line Example: dd Deletes the current line.
6️⃣ Copy & Paste (Very Important) Command Meaning yy copy line 5yy copy 5 lines p paste below P paste above Example: yy p Copy line → paste.
7️⃣ Undo / Redo Command Meaning u undo Ctrl + r redo DevOps life saver 😄
8️⃣ Search Like a Hacker 🔎 Search word: /error Next result: n Previous result: N Example: /password
9️⃣ Replace Words (Powerful) Replace in entire file: :%s/old/new/g Example: :%s/http/https/g
Replace with confirmation :%s/http/https/gc
🔟 Show Line Numbers (DevOps Trick) Inside vi: :set number Or shorter: :set nu
11️⃣ Edit Multiple Lines Fast ⚡ Insert text at start of many lines. Ctrl + v Then select lines → press: Shift + i Type text → press ESC. Example: Add # to comment multiple lines.
12️⃣ Open File Directly at Line Very useful for logs or errors. vi +120 file.txt Open file at line 120.
13️⃣ View Logs Like a Pro Example: vi /var/log/syslog Search: /error Jump: n
14️⃣ Split Screen Editing 🧠 Inside vim: :split file2.txt or :vsplit file2.txt Move between windows: Ctrl + w
15️⃣ Repeat Last Command (Very Powerful) Press: . Example: Delete word: dw Then repeat deletion: .
16️⃣ Delete a Word dw Delete 5 words 5dw
17️⃣ Change Word Quickly cw Delete word → enter insert mode.
18️⃣ Replace Character Move cursor to character. Press: r Then type new character. Example: rA
19️⃣ Run Command Without Leaving vi Example check file: :!ls Or: :!pwd
20️⃣ Exit Insert Mode Fast Instead of ESC: Ctrl + [ Works faster.
🧠 Real DevOps Examples Edit nginx config vi /etc/nginx/nginx.conf Edit Dockerfile vi Dockerfile Edit crontab crontab -e Edit AWS script vi deploy.sh
🚀 The 5 Commands Every Engineer Must Know Memorize these: i ESC dd yy p :wq
🏆 Pro Hacker Tricks Jump between brackets: % Indent line:
Unindent: <<