Skip to content
Go back

Vim cheatsheet

Published:

Here is a curated list of essential, real-world Vim commands. This list avoids esoteric tips and focuses on the core commands that form the daily workflow of developers, DevOps engineers, and sysadmins.

You can’t fix a server config or refactor code if you can’t move around efficiently.

Editing & Text Manipulation

This is where Vim’s power becomes obvious for quick edits.

Powerful Editing (Combining Motion)

This is the “Verb + Noun” philosophy that makes Vim legendary.

Searching and Replacing (The Sysadmin’s Best Friend)

Crucial for analyzing logs, debugging configs, and refactoring code.

File and Window Management

Essential for working with multiple files, which is a daily task.

Visual Mode (For Selecting Blocks of Text)

Real-World Scenarios

  1. Quick Log Analysis: vim /var/log/syslog. You see an error on line 1050. 1050G to jump right to it. Search for all occurrences of “timeout”: /timeout then press n to cycle through them.
  2. Editing a Config: You need to change a port number in nginx.conf. Find the line with /listen. Use cw to delete the old number and type the new one. Save and quit with :wq.
  3. Refactoring a Variable: You need to rename a function parameter from user_id to accountId. Put your cursor on user_id and press * to find all instances. At each one, press cw, type accountId, and press Esc. Then press n to go to the next occurrence and . to repeat the change.
  4. Commenting out a Block: You need to disable a section of a Python script. Move to the top of the block, press Ctrl + v, use j to select down, then press I (capital I), type #, and press Esc. The # will appear on every selected line.

Master these commands, and you will be significantly more efficient in any text-editing task on a server or your local machine. This is the core Vim that professionals use every day.


Suggest Changes

Previous Post
Guide to NFS on Linux
Next Post
MBR vs. GPT Don't Just Pick One—Understand the Difference!