My all-time favorite text editor is undoubtedly “Vi/Vim”. Vi/Vim is a venerable text and programming editor built directly into Apple’s macOS/OS X and Linux distributions, with full support for Microsoft Windows. Often heralded as one of the most powerful text editors in computing history, I simply love its distraction-free design and boundless extensibility—making it equally suited for focused long-form writing and idiosyncratic programmers.

Further Reading: The Legendary History of the Vi/Vim Text Editor

Because VI/VIM spans nearly the entire history of modern personal computing, an active global community has localized and extended it across languages. For example, in VimWiki: Creating a Personal Wiki and Journal in Vim, we explored how Vim extensions can transform the editor into a powerful offline personal knowledge base.

A defining characteristic of Vi/Vim is replacing the single “edit mode” of conventional word processors with distinct operational modes, providing three core environments:

  1. Normal Mode: The default state when launching Vi/Vim. Keystrokes act as operational commands rather than text input, allowing rapid navigation and manipulation without altering buffer content.
  2. Insert Mode: Entered by pressing keys like i or Insert (indicated by -- INSERT -- in the status bar). This mode allows traditional typing, insertion, and text edits. Pressing Esc returns to Normal Mode.
  3. Command-Line Mode (Cmdline Mode): Triggered from Normal Mode by typing : (colon). A : prompt appears at the bottom of the window, allowing you to execute file operations, search-and-replace patterns, and system commands. Pressing Esc returns to Normal Mode.

Official Website: Vim Online

Vi / Vim Essential Command Reference

Normal Mode (Toggled via Insert / i and Esc)

  • Cursor Navigation: h (left), j (down), k (up), l (right)
  • Character & Word Deletion: x, X, dw
  • Line Deletion, Copy & Paste: dd (delete/cut line), yy (yank/copy line), p / P (paste after/before)
  • Join Lines: J
  • Search & Repeat: /pattern, n (next match), N (previous match)
  • Undo & Redo: u (undo), Ctrl+r (redo)
  • Save and Quit: ZZ
  • Window Splitting: :sp [filename], :vs [filename]
  • Jump to Screen Positions: H (top of screen), M (middle), L (bottom), gg (first line of file), G (last line)
  • Jump Word by Word: w / W (next word start), b / B (previous word start)

Command-Line Mode (Enter via :)

  • Save and Exit: :w (write), :w! (force write), :q (quit), :q! (quit without saving), :wq or :x (write and quit)
  • Preferences: :set [option]
  • Global Replace: :%s/old/new/g
  • File Management: :edit filename, :split filename, :vsplit filename

File Operations & Exiting VI

  • :q — Quit VI (fails if unsaved changes exist)
  • :q! — Force quit VI, discarding all unsaved changes
  • :w — Save current file
  • :w [filename] — Save as new file with given filename
  • :wq or :x — Save changes and quit VI

Insert Mode Navigation & Entry

From Normal Mode, use these keys to enter Insert Mode:

  • i — Insert before cursor
  • I — Insert at beginning of line
  • a — Append after cursor
  • A — Append at end of line
  • o — Open a new line below current line and enter Insert Mode
  • O — Open a new line above current line and enter Insert Mode

Cursor Movement Shortcuts

  • k — Move up one line (equivalent to ↑)
  • j — Move down one line (equivalent to ↓)
  • h — Move left one character (equivalent to ←)
  • l — Move right one character (equivalent to →)
  • H — Move cursor to top of visible screen
  • M — Move cursor to middle of visible screen
  • L — Move cursor to bottom of visible screen
  • gg — Jump to the first line of the file
  • G — Jump to the last line of the file
  • b — Move cursor backward to start of previous word
  • e — Move cursor forward to end of next word
  • w — Move cursor forward to start of next word
  • ^ — Move cursor to first non-blank character of current line
  • :[number] — Jump directly to line [number] (e.g., :45)
  • [number]G — Jump directly to line [number] (e.g., 45G)

Screen Scrolling

  • Ctrl+f — Page down (forward full screen)
  • Ctrl+b — Page up (backward full screen)
  • Ctrl+d — Scroll down half a screen
  • Ctrl+u — Scroll up half a screen

Searching Text

  • /string — Search downward for specified string
  • ?string — Search upward for specified string
  • Matches highlight automatically. Press n to jump to next match, or N to jump to previous match.
  • Place cursor over any word and press * to search forward for that word, or # to search backward.

Copying, Cutting, and Deleting Text

  • yy or Y — Copy (yank) current line
  • p — Paste copied/cut text after cursor (or below current line)
  • P — Paste copied/cut text before cursor (or above current line)
  • [line1],[line2]co [line3] — Copy lines from line1 to line2 and insert after line3
  • dd — Delete (cut) current line
  • dw — Delete from cursor to next word
  • cc — Clear entire line and enter Insert Mode
  • cw — Change word from cursor to word end and enter Insert Mode
  • D — Delete from cursor to end of line
  • [line1],[line2]m [line3] — Move lines from line1 to line2 to after line3
  • [line1],[line2]d — Delete lines from line1 through line2
  • :%s/search_term/replace_term/g — Globally replace all occurrences in buffer

Bookmarks (Marks)

Marks let you tag locations within text: lowercase letters a–z for file-local marks, and uppercase letters A–Z for cross-file global marks.

  • m[a-z] — Set bookmark at current cursor position
  • '[a-z] — Jump to line containing mark
  • `[a-z] — Jump to exact character position of mark
  • :marks — Display active mark table

Productivity & Configuration

  • u — Undo previous action
  • Ctrl+r — Redo undone action
  • K — Lookup documentation: In C/C++ code, pressing K over a library function opens its man page
  • = — Auto-format indentation: Navigate to top (gg), enter visual mode (v), select to bottom (G), then press =
  • :set all — Display all active configuration options
  • :set nu — Show line numbers (:set nonu to hide)
  • :set autoindent — Enable automatic indentation (:set noautoindent to disable)
  • :set tabstop=4 — Set tab width (default is often 8; setting to 4 is common for modern development)
  • :set background=dark — Optimize keyword syntax colors for dark terminal backgrounds (:set background=light for bright themes)
  • :split [filename] — Split window horizontally; switch between windows using Ctrl+w followed by directional keys
  • :vsplit [filename] — Split window vertically

To make settings permanent without reconfiguring on every launch, create a .vimrc file in your home directory (~/.vimrc on macOS/Linux, or _vimrc in the user folder on Windows):

set background=dark
set autoindent
set number
set tabstop=4
set shiftwidth=4
set expandtab

Conclusion

The enduring popularity of VI and Vim is well-earned. Unlike rudimentary editors like Windows WordPad, which historically choked on huge text files, VI/Vim handles massive datasets with ease. More importantly, its cross-platform presence across Windows, macOS, and Linux ensures a completely unified workflow and universal design paradigm wherever you compute.

Best of all: Vi/Vim remains completely free and open-source.

Originally published December 25, 2010; revised December 25, 2015.

✦ Independent Journalism · Reader Support ✦

Support Independent Perspectives & In-Depth Insights

Every thoughtful analysis and candid critique comes from our dedication to truth and quality. We choose not to follow sensational algorithms or clickbait headlines.

Sustaining independent research requires reader support. Make a one-time or monthly contribution, securely processed by Google.

Payments secured by Google · Manage or cancel anytime in your Google Account