Getting Started with Vim Editor


Vim (Vi IMproved) is a highly configurable text editor built to enable efficient text editing. It is pre-installed on almost every Unix system in the world, making it a critical skill for any Linux administrator or developer.

The Concept of Modes

The biggest hurdle for beginners is understanding that Vim operates in different “modes”. You cannot simply open a file and start typing.

  1. Normal Mode (Command Mode): This is the default mode when you open Vim. In this mode, keys act as commands (e.g., copying, deleting, navigating). You cannot type regular text here.
  2. Insert Mode: This is where you actually type text. You enter this mode from Normal Mode.
  3. Visual Mode: Used for highlighting blocks of text.

Basic Navigation and Editing

To open a file, type:

vim filename.txt

Entering Insert Mode: Press i to enter Insert Mode. Now you can type as you would in a normal text editor.

Returning to Normal Mode: Press the Esc key. Always press Esc when you are done typing to return to Command mode.

Navigating in Normal Mode: While you can use arrow keys, standard Vim navigation uses the home row:

  • h: Left
  • j: Down
  • k: Up
  • l: Right

Saving and Quitting

This is where many beginners get stuck. To save or quit, you must be in Normal Mode (press Esc). Then, type a colon (:) followed by a command:

  • :w - Write (save) the file.
  • :q - Quit. Vim will warn you if you have unsaved changes.
  • :wq or :x - Save and quit.
  • :q! - Force quit, discarding any unsaved changes.

Vim has a steep learning curve, but its efficiency and ubiquity make it an invaluable tool to master. To practice interactive lessons, run the command vimtutor in your terminal.