Mastering VIM Editor – Shortcuts for the Modern DevOps Engineer
⚡ Mastering VIM Editor – Shortcuts for the Modern DevOps Engineer
VIM (Vi IMproved) isn’t just a text editor — it’s a rite of passage. A timeless tool that’s faster than any GUI editor once you master the muscle memory. Whether you’re editing configs in /etc/, tweaking Dockerfiles, or live-patching in production like a boss — VIM is your best ally.
🧠 Understanding the Modes in VIM
VIM operates in multiple modes — and switching between them is the secret sauce to your speed.
| Mode | Purpose |
|---|---|
| Normal | Navigate and execute commands (default mode) |
| Insert | Edit text (press i, a, etc. to enter; Esc to exit) |
| Visual | Select and manipulate text (press v, V, or Ctrl + v) |
| Command-line | Save, quit, search (press : in Normal mode) |
🚀 Navigation Essentials
Move like a ninja through your files:-
h– Leftl– Rightj– Downk– Up0– Start of the line^– First non-whitespace character$– End of the linew– Next wordb– Previous wordgg– Start of fileG– End of file:n– Jump to line numbernCtrl + o/Ctrl + i– Jump backward/forward in jump history
✍️ Insert Mode Commands
Jump in and out of insert mode like a pro:
i– Insert before cursorI– Insert at the start of linea– Append after cursorA– Append at the end of lineo– New line belowO– New line aboveEsc– Back to normal mode
✂️ Editing and Manipulating Text
Keep your hands on the keyboard and your edits sharp:
x– Delete character under cursorX– Delete character before cursordw– Delete a worddd– Delete entire lined$/D– Delete to end of lined0– Delete to start of lineu– UndoCtrl + r– Redoyy– Yank (copy) a lineyw– Yank a wordp– Paste after cursorP– Paste before cursor~– Toggle case of character under cursor
🔍 Searching & Replacing Like a Wizard
/pattern– Search forward?pattern– Search backwardn/N– Repeat search forward/backward:%s/old/new/g– Replace all in file:s/old/new/g– Replace all in current line:%s/old/new/gc– Replace with confirmation
🧩 Visual Mode (VIM only)
Selection mode that Vi dreams of having:
v– Start character-wise selectionV– Start line-wise selectionCtrl + v– Block-wise (column) selectiony– Yank selectiond– Delete selection>/<– Indent left/right
🗂️ Managing Multiple Files & Splits
Because multitasking is life:
:e filename– Open a file:w– Save:wq– Save and quit:q!– Quit without saving:split filename– Split window horizontally:vsplit filename– Split window verticallyCtrl + w + w– Switch between windowsCtrl + w + [h/j/k/l]– Move in split direction:tabnew filename– Open file in new tabgt/gT– Next / previous tab
🧠 Pro Tips for DevOps Warriors
:set number– Show line numbers (great for debugging logs or YAML):set relativenumber– Relative line numbers (for quickd10j, etc.):syntax on– Turn on syntax highlighting:set paste– Paste without auto-indentation issues:!command– Run shell command (yes, eventerraform plan)
💡 TL;DR Cheatsheet
| Task | Command |
|---|---|
| Save and quit | :wq |
| Quit without saving | :q! |
| Undo | u |
| Redo | Ctrl + r |
| Search | /pattern |
| Replace all | :%s/old/new/g |
| Yank & paste line | yy, p |
| Jump to start | gg |
| Jump to end | G |
✨ “Once you go VIM, you never dim.” Start slow, stick with it, and soon your fingers will dance like they know the script.