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.

ModePurpose
NormalNavigate and execute commands (default mode)
InsertEdit text (press i, a, etc. to enter; Esc to exit)
VisualSelect and manipulate text (press v, V, or Ctrl + v)
Command-lineSave, quit, search (press : in Normal mode)

🚀 Navigation Essentials

Move like a ninja through your files:-

  • h – Left
  • l – Right
  • j – Down
  • k – Up
  • 0 – Start of the line
  • ^ – First non-whitespace character
  • $ – End of the line
  • w – Next word
  • b – Previous word
  • gg – Start of file
  • G – End of file
  • :n – Jump to line number n
  • Ctrl + 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 cursor
  • I – Insert at the start of line
  • a – Append after cursor
  • A – Append at the end of line
  • o – New line below
  • O – New line above
  • Esc – Back to normal mode

✂️ Editing and Manipulating Text

Keep your hands on the keyboard and your edits sharp:

  • x – Delete character under cursor
  • X – Delete character before cursor
  • dw – Delete a word
  • dd – Delete entire line
  • d$ / D – Delete to end of line
  • d0 – Delete to start of line
  • u – Undo
  • Ctrl + r – Redo
  • yy – Yank (copy) a line
  • yw – Yank a word
  • p – Paste after cursor
  • P – Paste before cursor
  • ~ – Toggle case of character under cursor

🔍 Searching & Replacing Like a Wizard

  • /pattern – Search forward
  • ?pattern – Search backward
  • n / 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 selection
  • V – Start line-wise selection
  • Ctrl + vBlock-wise (column) selection
  • y – Yank selection
  • d – 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 vertically
  • Ctrl + w + w – Switch between windows
  • Ctrl + w + [h/j/k/l] – Move in split direction
  • :tabnew filename – Open file in new tab
  • gt / 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 quick d10j, etc.)
  • :syntax on – Turn on syntax highlighting
  • :set paste – Paste without auto-indentation issues
  • :!command – Run shell command (yes, even terraform plan)

💡 TL;DR Cheatsheet

TaskCommand
Save and quit:wq
Quit without saving:q!
Undou
RedoCtrl + r
Search/pattern
Replace all:%s/old/new/g
Yank & paste lineyy, p
Jump to startgg
Jump to endG

“Once you go VIM, you never dim.” Start slow, stick with it, and soon your fingers will dance like they know the script.