Vim is a free, open source text editor for programs and other plain text. It runs on Windows, macOS, and Unix systems, with terminal and graphical interfaces. Its charityware license encourages voluntary donations.
Commands act on text
Normal mode interprets keystrokes as editing commands; Insert mode enters text. Pressing i starts insertion, and Escape returns to Normal mode. Movement commands travel through characters, words, lines, and larger text regions.
Operators combine an action with a movement or text object. A delete operation can target a word, several words, or the rest of a line. Change replaces its target and enters Insert mode. Text objects distinguish a word’s contents from the word plus surrounding whitespace.
Visual mode provides another selection method. Character selection targets a text span, line selection targets whole lines, and block selection targets a rectangle. Operators then act on that selection.
Patterns and replacement ranges
Vim searches forward or backward for a pattern. Repeat commands move through subsequent matches, while a case option controls whether uppercase and lowercase letters differ. Searching for the cursor’s word adds word boundaries automatically.
Substitution combines a search pattern, replacement text, and line range. Its default changes the first match on the current line. A whole-file range broadens the target; the global flag replaces every match per line. Confirmation prompts let the user accept individual replacements.
The argument list defines a collection of files. The argdo command applies an editing command across that list, and update writes files only when their buffers contain changes.
Registers and recorded actions
Yank copies text into a register, while delete can store text before removing it. Named registers hold separate fragments for later insertion, including across files. Put restores the fragment’s character, line, or block shape.
Vim also records command sequences into registers. Recording starts with a register choice and ends with another recording command. Playback repeats those keystrokes from the current cursor position. A count repeats the macro several times; its results depend on the text and movements it encounters.
Several views of the work
Vim separates file contents from their onscreen arrangement:
| Element | Role |
|---|---|
| Buffer | Holds a file’s text in memory until a write updates the disk file. |
| Window | Shows a buffer; several windows can show different positions in the same buffer. |
| Tab page | Groups windows into another arrangement. |
Horizontal and vertical splits can display different files or different locations within one file. Window controls move focus and resize those views.
Diff mode highlights differences between files, folds matching regions, and coordinates scrolling. Commands jump between differences or transfer a differing block from one window to another. Writing the destination buffer saves the change.
History, recovery, and sessions
Undo and redo navigate editing history. If a user undoes an edit and makes another change, Vim retains alternative history branches. Chronological navigation and earlier or later time commands reach those alternatives.
The undofile option saves undo history when the user writes a file and restores it on reopening. Swap files support recovery after an interruption, although a crash can lose the latest changes. Session files serve a different purpose: they preserve file lists, window arrangements, and configuration choices for later restoration.
Code structure and external diagnostics
File types select syntax highlighting rules. Insert-mode word completion searches configurable sources, including current and other buffers. Folding collapses line ranges without deleting their text; users can open individual folds or change several fold levels.
A separate ctags program creates an index of symbol definitions. Vim follows those entries to definitions, including locations in other files. The make command runs an external build tool and collects diagnostics in the quickfix list. Users move between entries to visit their file and line locations.
Spelling within a text buffer
A language setting selects spelling dictionaries. Vim highlights questionable words and provides commands to visit them. Its suggestions list replaces the cursor’s word with a chosen alternative, while the personal word list accepts specialist vocabulary. These tools check spelling rather than grammar.
Mappings, scripts, and terminal jobs
The vimrc configuration file supplies startup options and commands. Mappings associate key sequences with editing actions. Autocommands run commands when matching events and filename patterns occur, such as before a file write. Vim script plugins can add commands, settings, and external integrations.
Builds with terminal support run a shell or another external job inside an editor window. That job continues asynchronously while the user edits elsewhere. In Terminal-Job mode, keyboard input reaches the job when its terminal window has focus.





