VI vs VIM - Differences, Features, and When to Use Each

Introduction

VI and VIM are two of the most important editors in the Unix/Linux world. Understanding their relationship, differences, and strengths helps you make the right choice — and use each one more effectively.

What You'll Learn:

A Brief History

VI — The Original

VI (Visual Interface) was written by Bill Joy in 1976 as part of BSD Unix. It was built on top of ex, a line editor, and introduced the now-familiar modal editing paradigm — separate modes for inserting text and issuing commands.

# VI milestones: 1976 - Bill Joy writes vi at UC Berkeley 1979 - Included in BSD Unix 2.0 1980s - Becomes the de facto standard Unix editor 1992 - POSIX standardizes vi behavior Today - Ships on virtually every Unix/Linux system

VIM — VI Improved

VIM (Vi IMproved) was written by Bram Moolenaar and first released in 1991 for the Amiga, then ported to Unix/Linux. The goal was to extend vi with modern features while remaining fully backward compatible.

# VIM milestones: 1988 - Bram Moolenaar starts development (Amiga) 1991 - VIM 1.0 released 1993 - VIM 2.0, Unix port 1994 - VIM 3.0, multiple windows 1996 - VIM 4.0, GUI support (gvim) 1998 - VIM 5.0, syntax highlighting 2001 - VIM 6.0, folding, plugins 2006 - VIM 7.0, spell checking, tabs 2016 - VIM 8.0, async I/O, packages 2022 - VIM 9.0, Vim9script language
Key Relationship: VIM is a strict superset of VI. Every valid vi command works identically in vim. Vim simply adds more capabilities on top.

Feature Comparison

Feature VI VIM
Modal editing ✓ Yes ✓ Yes
Ex commands ✓ Yes ✓ Yes (extended)
Search and replace ✓ Yes ✓ Yes (extended regex)
Syntax highlighting ✗ No ✓ Yes
Multiple undo levels ✗ No (single undo) ✓ Yes (unlimited)
Multiple windows/splits ✗ No ✓ Yes
Multiple buffers/tabs ✗ No ✓ Yes
Visual mode (v, V, Ctrl+v) ✗ No ✓ Yes
Plugin support ✗ No ✓ Yes
Spell checking ✗ No ✓ Yes
Folding ✗ No ✓ Yes
Autocompletion ✗ No ✓ Yes (Ctrl+n/p)
Persistent undo (undofile) ✗ No ✓ Yes
Diff mode (vimdiff) ✗ No ✓ Yes
Scripting language ✗ No ✓ Vimscript / Vim9script
GUI version ✗ No ✓ gvim
Macro recording (q) Limited ✓ Full support
Marks ✓ Basic ✓ Extended
Configuration file ~/.exrc ~/.vimrc (also reads .exrc)
POSIX compliant ✓ Yes ✓ Yes (in compatible mode)

The Single Undo Problem

This is the most important practical difference for daily use. In true vi, u is a toggle — it undoes, then re-does, then undoes again. There is effectively only one level of undo.

VI Behavior:
u # Undo last change u # Re-does it (toggles back!) u # Undoes again # You cannot go back multiple steps
VIM Behavior:
u # Undo last change u # Undo the change before that u # Undo the change before that # ...continues back through full history Ctrl+r # Redo forward through history
Critical Sysadmin Note: If you are ever working on a system that only has true vi (rare but it happens — minimal installs, some BSDs, recovery environments), remember that u toggles. Pressing it twice does NOT give you back a clean file — it puts you right back where you started.

Visual Mode — VIM Only

One of the most used vim additions. Visual mode lets you select text visually before operating on it. True vi has no visual mode at all.

v # Character visual mode — select char by char V # Line visual mode — select whole lines Ctrl+v # Block visual mode — select rectangular blocks # After selecting: d # Delete selection y # Yank (copy) selection c # Change selection > # Indent selection < # De-indent selection : # Run ex command on selection
Block Visual Mode Example (VIM only):
# Insert # at the start of 5 lines simultaneously: Ctrl+v # Enter block visual mode 4j # Select 5 lines I # Insert at start of block # # Type the character Esc # Applied to all selected lines
TRY IT: Open any config file in vim. Press Ctrl+v, select a column of text with arrow keys, then press d. You just deleted a column — impossible in true vi.

Syntax Highlighting

VIM only. Syntax highlighting colors your text based on file type — shell scripts, Python, HTML, config files, and hundreds more are supported out of the box.

:syntax on # Enable syntax highlighting :syntax off # Disable :set filetype=sh # Force shell script highlighting :set filetype=html # Force HTML highlighting :set filetype= # Clear filetype :colorscheme desert # Change color scheme :colorscheme # (tab) to cycle through available schemes
In ~/.vimrc to always enable:
syntax on filetype plugin indent on set background=dark
Sysadmin Value: Syntax highlighting catches errors before you run scripts. A misquoted string or unclosed bracket shows up in the wrong color immediately.

Multiple Windows and Splits

VIM only. You can split the screen horizontally or vertically and edit different files — or different parts of the same file — simultaneously.

:split filename # Horizontal split :vsplit filename # Vertical split :sp # Short form of split :vsp # Short form of vsplit # Navigate between splits: Ctrl+w h # Move left Ctrl+w j # Move down Ctrl+w k # Move up Ctrl+w l # Move right Ctrl+w w # Cycle through windows # Resize splits: Ctrl+w + # Taller Ctrl+w - # Shorter Ctrl+w = # Equal size :close # Close current split :only # Close all splits except current
Practical Example — Edit and Reference Simultaneously:
vim script.sh :vsplit /etc/sysconfig/network-scripts/ifcfg-eth0 # Left: your script Right: reference config # Both fully editable, copy/paste between them with y and p

Diff Mode — vimdiff

VIM includes a built-in diff viewer. This is one of the most useful sysadmin features — compare config files, spot changes between versions, merge differences.

# From the command line: vimdiff file1 file2 vimdiff file1 file2 file3 # Up to 4 files # From inside vim: :diffsplit file2 # Open diff split :diffthis # Mark current window for diff :diffoff # Turn off diff mode # Navigate differences: ]c # Next difference [c # Previous difference # Merge differences: do # diff obtain (pull change from other file) dp # diff put (push change to other file) :diffupdate # Refresh diff highlighting
Sysadmin Use Case: Before and after a config change, vimdiff /etc/ssh/sshd_config.bak /etc/ssh/sshd_config shows exactly what changed — color coded, navigable, and you can revert individual differences with do.

Running VIM in Compatible Mode

VIM can behave almost exactly like true vi using compatible mode. This is useful for writing scripts that must work on both, or for testing true vi behavior.

vim -C filename # Start in compatible mode vim --cmd "set cp" # Same effect # Inside vim: :set compatible # Enable vi-compatible mode :set nocompatible # Enable all vim features (default) :set compatible? # Check current setting
Note: Many vim features (visual mode, multiple undo, plugins) are disabled in compatible mode. Most modern .vimrc files start with set nocompatible to ensure full vim behavior.

Checking What You Actually Have

On many Linux systems, vi is actually a symlink to vim, or a minimal vim build. Always verify what you're working with.

# Check the vi binary: which vi ls -la $(which vi) file $(which vi) # Check version: vi --version vim --version # Inside the editor: :version # Check if it's really vim: vi --version | grep VIM vi --version | grep -i "small\|normal\|big\|huge" # On RHEL/CentOS/Rocky: rpm -q vim-minimal vim-enhanced # On Debian/Ubuntu: dpkg -l vim vim-tiny vim-nox # Common symlink situations: ls -la /usr/bin/vi /usr/bin/vim /usr/bin/nvi
VIM Build Levels — What's Installed Matters:
vim-tiny # Minimal — very few features, common in containers vim-minimal # RHEL name for reduced vim vim-small # Small feature set vim-normal # Standard features vim-big # More features, more syntax files vim-huge # All features including Python/Ruby scripting vim-nox # No X (GUI), full features — ideal for servers gvim # GUI version (requires X/Wayland)

When to Use VI vs VIM

Use True VI (or vi-compatible) When:

Use VIM When:

Sysadmin Reality: On modern RHEL, Rocky, Ubuntu, and Debian servers, vi is almost always vim under the hood. The days of encountering true vi on production Linux are rare. But knowing the difference matters when you hit a minimal recovery environment or a locked-down appliance.

Behavior Differences to Watch For

Behavior True VI VIM
Undo (u) Toggles last change only Steps back through full history
Arrow keys in insert mode May insert garbage characters Work correctly
Backspace in insert mode Limited — may not cross line breaks Fully configurable via backspace option
:%s with \w, \d May not be supported Full extended regex support
Mouse support No Yes (:set mouse=a)
Clipboard integration No Yes ("+y, "+p)
Line wrapping display Basic Configurable, with linebreak
UTF-8 / Unicode Limited Full support

NVI — A Third Option

On BSD systems (FreeBSD, OpenBSD, macOS historically), you may encounter nvi — New VI. It is a clean reimplementation of vi that is closer to true POSIX vi than vim, but adds a few modest improvements.

# nvi has: - Multiple undo (unlike true vi) - Multiple file buffers - Background editing # nvi does NOT have: - Syntax highlighting - Visual mode - Plugins - Most vim extensions # Check if you have nvi: nvi --version file $(which vi) # May show "nvi" on BSD systems
macOS Note: macOS ships with vim (not nvi) since OS X 10.9. However it is often an older build. Many admins install a current vim via Homebrew: brew install vim

Quick Reference — VIM-Only Commands

If you use these commands, you are using VIM features. They will not work in true vi.

# Visual mode: v / V / Ctrl+v # Multiple undo/redo: u (multiple times) Ctrl+r # Window splits: :split / :vsplit Ctrl+w [hjkl] # Tabs: :tabnew / :tabnext / :tabprev gt / gT # Diff: vimdiff / :diffsplit / do / dp # Completion in insert mode: Ctrl+n / Ctrl+p # Spell check: :set spell / ]s / [s / z= # Folding: zf / zo / zc / za # Persistent undo: :set undofile # Netrw file browser: :Explore / :Sex / :Vex

Summary

Bottom Line: Learn vi so you can work anywhere. Use vim so you can work efficiently.

← Back to VI Index ↑ Back to EXPANDED