Vi Cheat Sheet – Master Editing Fast in 2025

Vi cheat sheet is one of the most requested resources by developers, system admins, and DevOps engineers. Since Vi is the default text editor on most Unix and Linux systems, mastering its commands is essential.

This guide brings you the most practical and easy-to-follow Vi cheat sheet covering modes, navigation, editing, search, and advanced features. By the end, you’ll be editing files like a pro without wasting time searching for commands.

What is Vi Editor?

Vi is a powerful screen-oriented text editor originally created for Unix systems. Unlike GUI-based editors, Vi is lightweight and always available in almost every Linux distribution.

Its design focuses on efficiency. Instead of menus and buttons, Vi relies on commands and keyboard shortcuts. Once you learn them, editing becomes incredibly fast compared to traditional editors.

Many modern editors like Vim are based on Vi, but learning Vi basics ensures you can work effectively on any Linux machine, even in restricted environments.

Modes in Vi Editor

One of the most important concepts in this Vi cheat sheet is understanding its modes. Vi has three main modes, and switching between them is essential for smooth editing.

1. Normal Mode

  • The default mode after opening a file.
  • Used for navigation, deleting, copying, and other commands.
  • Press Esc anytime to return to this mode.

2. Insert Mode

  • Allows text entry and modifications.
  • Enter with keys: i (insert before cursor), a (append after cursor), or o (open new line).

3. Command-Line Mode

  • Used for saving, quitting, and executing advanced commands.
  • Accessed by typing : from Normal Mode.

Opening and Saving Files in Vi

Knowing how to start and exit Vi is the first step.

  • Open a file:
vi filename
  • Save changes and exit:
:wq
  • Save without exiting:
:w
  • Quit without saving:
:q!

These commands form the backbone of any Vi cheat sheet because they are used every time.

Basic Navigation Commands

Moving efficiently inside Vi is critical. Here are the most common navigation commands:

  • h → Move left
  • l → Move right
  • j → Move down one line
  • k → Move up one line
  • 0 → Move to beginning of line
  • $ → Move to end of line
  • w → Jump to next word
  • b → Jump back one word
  • G → Go to end of file
  • gg → Go to beginning of file

These shortcuts make Vi much faster than arrow keys.

Editing Text in Vi

This section of the Vi cheat sheet highlights editing commands that make you more productive.

  • x → Delete character under cursor
  • dw → Delete a word
  • dd → Delete a line
  • yy → Copy (yank) a line
  • p → Paste after cursor
  • u → Undo last change
  • Ctrl + r → Redo

For inserting:

  • i → Insert before cursor
  • a → Insert after cursor
  • o → Open new line below

Searching and Replacing in Vi

Finding and replacing text is a frequent task. Vi provides powerful commands for this:

  • Search forward: /word
  • Search backward: ?word
  • Next match: n
  • Previous match: N

Replace commands:

  • Replace word under cursor: cw
  • Replace entire line: cc
  • Global replace: :%s/old/new/g

This is one of the most useful parts of any Vi cheat sheet because it saves hours of manual edits.

Working with Multiple Files

Vi also allows working with multiple files in the same session.

  • Open multiple files:
vi file1 file2
  • Switch to next file:
:n
  • Switch back:
:prev
  • View list of files:
:args

This is useful when editing configuration files across multiple services.

Visual Mode in Vi

Vi includes a visual mode that allows selecting blocks of text before performing actions.

  • Enter visual mode: v (character), V (line), or Ctrl + v (block).
  • After selection, you can delete (d), copy (y), or replace.

This feature is less known but extremely powerful, especially for column editing.

Advanced Commands for Productivity

Here are some advanced commands worth adding to your Vi cheat sheet:

  • Indent a line: >>
  • Outdent a line: <<
  • Repeat last command: .
  • Join two lines: J
  • Open new shell inside Vi: :!bash
  • Show line numbers: :set number
  • Disable line numbers: :set nonumber

Mastering these shortcuts speeds up complex editing tasks.

Vi vs. Vim – Do You Need Both?

While this blog focuses on Vi cheat sheet, many developers use Vim, an extended version of Vi with plugins and customization.

  • Vi is lightweight and available on all systems.
  • Vim offers syntax highlighting, multiple undo levels, and scripting.
  • If you’re working on servers, knowing Vi is essential because Vim might not always be installed.

Think of Vi as your survival tool and Vim as your enhanced editor.

Practical Use Cases of Vi

Here are real-world scenarios where this Vi cheat sheet comes in handy:

  • Editing server configuration files (e.g., nginx.conf, sshd_config).
  • Writing and debugging shell scripts.
  • Quick text manipulations inside a terminal session.
  • Working with large log files.

In each case, Vi proves to be reliable, fast, and always available.

Vi Cheat Sheet Table (Quick Reference)

ActionCommand
Open Filevi filename
Save & Exit:wq
Quit Without Saving:q!
Insert Modei, a, o
Delete Linedd
Copy Lineyy
Pastep
Undou
RedoCtrl + r
Search/word
Replace:%s/old/new/g

Conclusion

This Vi cheat sheet is designed to make your editing faster, smoother, and more efficient. By mastering these commands, you’ll never struggle with text editing on Linux servers again.

The more you practice, the more natural these commands will feel. Start with the basics, then gradually add advanced techniques to your workflow.

FAQs on Vi Cheat Sheet

1. What is the difference between Vi and Vim?

Vi is the original Unix text editor, while Vim (Vi Improved) offers extra features like syntax highlighting, multiple undo, and plugins.

2. How do I exit Vi editor quickly?

Type :wq to save and quit, or :q! to exit without saving changes.

3. Can I use arrow keys in Vi?

Yes, but it’s faster to use h, j, k, and l for navigation.

4. Is Vi available on all Linux systems?

Yes, Vi is part of the default installation on almost every Unix/Linux distribution.

5. Why should I learn Vi if Vim is better?

Because Vi is always available on minimal systems, especially in server environments, making it a must-know tool.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top