DEV Community

Nisal Sashmitha
Nisal Sashmitha

Posted on • Originally published at Medium on

VIM Modes: The Heart of VIM (Linux VI Editor — part 2)

VIM Modes: The Heart of VIM (Linux VI Editor — part 2)

📖 Overview Note: This is an overview of VIM modes. You’ll learn these concepts in more depth as we explore other VIM features. Being aware of modes and understanding what they do will really help you quickly learn other features of the VI editor. You’ll need to work between these modes to practice all upcoming tasks!

What Makes VIM Different?

One of the key features that makes VIM different from other editors is its concept of modes. While most editors have just one mode where you type and use menus, VIM has distinct modes for different tasks.

The Three Main Modes

1. Normal Mode (Command Mode)

  • Default mode when you start VIM
  • Anything you type in Normal mode is a command
  • Used for navigation, deletion, copying, and other file operations
  • VIM is case sensitive — d and D do different things!

2. Insert Mode

  • Used for actually typing and adding text to your file
  • To enter Insert mode: Press i (or other insert commands)
  • To exit Insert mode: Press Escape

3. Line Mode (Command Line Mode)

Line mode is also called Last Line Mode or Command Line Mode. You use line mode to:

  • Save files (:w)
  • Quit VIM (:q)
  • Go to exact locations in the file (:10 goes to line 10)
  • Search and replace text
  • Execute advanced commands
  • Set VIM options and preferences

Your First VIM Session

Let’s create a file and practice moving between modes:

Create and open a new file

vim myfile.txt
Enter fullscreen mode Exit fullscreen mode

Once VIM opens, you’ll be in Normal mode. Here’s how to move between modes:

You start in NORMAL MODE

Press ‘i’ to enter INSERT MODE

Now type some text

Press Escape to return to NORMAL MODE

Press : to enter command mode, then type w to save or wq to save and quit. If you type w, you’ll return to normal mode after saving.

Mode flow

Visual Mode (Bonus)

There’s also Visual Mode for selecting text:

  • To enter: Press v in Normal mode
  • Purpose: Select text for copying, deleting, or formatting
  • To exit: Press Escape

Complete Mode Switching Examples

# Starting in Normal mode
i # Enter Insert mode
<Esc> # Back to Normal mode
: # Enter Line mode
<Esc> # Back to Normal mode (abandon command)
:w # Enter Line mode and save
<Enter> # Execute command, return to Normal mode
v # Enter Visual mode
<Esc> # Back to Normal mode
Enter fullscreen mode Exit fullscreen mode

Other Modes Exist Too!

VIM has additional modes like:

  • Replace mode
  • Binary mode
  • Org mode

These are slight variations of the main modes and you’ll learn about them later as you become more comfortable with VIM.

Summary & Tips

  • Three main modes: Normal (commands), Insert (typing), Line (file operations)
  • Always start in Normal mode when opening VIM
  • Escape is your friend — it always returns you to Normal mode
  • Case sensitivity matters — i and I are different commands
  • Line mode starts with : - used for file operations and advanced commands
  • Practice mode switching — it becomes second nature quickly

💡 Pro Tip: When in doubt, press Escape twice to ensure you're in Normal mode, then proceed with your desired command. This is a safe way to "reset" your mode state!

Next : Master VIM navigation and movement commands to efficiently move around your files!

✈️ This is a article I wrote as a contribution to a open-source DevOps Roadmap repository . While it focuses on the Vi editor, the repo includes many other valuable resources to support your DevOps journey — be sure to check them out too!

Top comments (0)