Most people meet the Vim text editor by accident. A git commit without -m, a crontab -e on a server, or vi on a rescue system opens a screen with a column of tildes, and typing letters seems to do random things. Those letters are commands, because Vim starts in normal mode, and once that is clear the rest is a small grammar of operators and motions.
What the Vim text editor is
Vim stands for "Vi IMproved". Its reference manual describes an editor that "includes almost all the commands from the Unix program 'Vi' and a lot of new ones", and Bram Moolenaar wrote most of it. It runs in a terminal, so it works the same over SSH as on your laptop, and there are graphical builds such as GVim on Windows and MacVim on macOS.
Commands are typed on the letter keys, so hands stay on the home row and eyes stay on the text. Without a single plugin, the Vim text editor has syntax highlighting, macros, regular expression search, split windows and tab pages.
Installing Vim and running vimtutor
Many Linux systems already have some form of vi. Check the version first:
$ vim --version | head -1
VIM - Vi IMproved 9.1 (2024 Jan 02, compiled Aug 24 2026 22:13:04)If the command is missing, install it from your distribution's package sources: sudo apt install vim on Debian and Ubuntu, sudo dnf install vim-enhanced on Fedora, sudo pacman -S vim on Arch Linux. On macOS a vim binary is usually present already; MacVim adds the GUI.
Then run vimtutor. It opens a copy of a practice file (Version 1.7 of the tutor on Vim 9.1) whose introduction puts the time needed at 30 minutes, and since it is a copy, wrecking it costs nothing.

Vim modes: normal, insert, visual and command-line
Vim has several modes, but four matter on day one:
| Mode | How you get there | What keys do |
|---|---|---|
| Normal | Esc from anywhere | Move, delete, copy, paste, start other modes |
| Insert | i, a, o, A and others | Type text as in any editor |
| Visual | v (characters), V (lines), Ctrl-v (block) | Select text, then apply an operator |
| Command-line | :, / or ? | Type an Ex command or a search pattern |
Normal mode is home base, and the Vim normal mode commands further down all start from it: enter insert mode to type, then press Esc the moment you stop. Of the insert commands, i inserts before the cursor, a after it, A at the end of the line, and o opens a new line below.
How to exit Vim
Knowing how to exit Vim starts with one key. Press Esc first (twice does no harm) so you are in normal mode, then pick one:
| Command | What it does |
|---|---|
:q | Quit. Refuses if there are unsaved changes |
:q! | Quit and discard changes |
:wq | Write the file, then quit (always writes) |
:x | Write only if the buffer changed, then quit |
ZZ | Normal-mode shortcut, the same as :x |
ZQ | Normal-mode shortcut, the same as :q! |
With several files open, :qa quits all of them and :qa! abandons every change. :q on a modified buffer gets this answer at the bottom of the screen:
E37: No write since last change (add ! to override)The file is fine; Vim is holding on to edits that were never written. A related message appears with :wq in a buffer that never had a name, E32: No file name, and :w notes.txt gives it one.
Git is the usual reason to learn how to exit Vim. It takes its editor from $GIT_EDITOR, core.editor, $VISUAL and $EDITOR in that order, then falls back to a default that the git-var manual calls "usually vi". On Ubuntu 24.04 the packaged Git uses the system editor command instead, which points to nano on a fresh install. The githug exercises produce plenty of commit messages to practice on.
Which Vim normal mode commands to learn first
Vim normal mode commands follow a pattern: an operator, then a motion or text object, optionally with a count. d deletes, c changes (deletes and enters insert mode), y yanks (copies). Motions say how far: w to the next word, b back one word, 0 to column one, ^ to the first non-blank character, $ to the end of the line, gg to the first line, G to the last.
Combined, they read almost like sentences. Each of these was run in Vim 9.1 on a test buffer:
| Keys | Effect |
|---|---|
dw | Delete from the cursor to the start of the next word |
d2w | Delete two words (a count in front of the motion) |
3x | Delete three characters under and after the cursor |
ci" | Change the text inside the next pair of double quotes on the line |
diw | Delete the word under the cursor, leaving the spaces |
u / Ctrl-r | Undo / redo |
. | Repeat the last change |
ci" tends to win people over. On the line let name = "old value"; with the cursor at the very start, ci"new followed by Esc produced let name = "new";, because Vim searched forward on the line for the quotes. Text objects come in pairs: on foo bar baz with the cursor on bar, daw left foo baz, while diw left two spaces between the words.
The arrow keys work in every mode, but the Vim trainer only counts h j k l and the word motions, which builds the habit faster than tables do.

Search, replace and registers
/pattern searches forward and ?pattern backward, with regular expressions. n jumps to the next match, N to the previous one, and * searches for the word under the cursor.
Replacement is an Ex command. :%s/old/new/g replaces every match in the file (% is the range "all lines", g means every match on each line, not only the first). Add c to confirm each one: :%s/old/new/gc stops at every match and accepts y to substitute, n to skip, l to substitute this one and stop, and Esc to quit. On the test line print the old old line, :%s/old/new/g gave print the new new line.
Registers are Vim's clipboards. Every delete, change and yank lands in the unnamed register "", which is what p pastes. A named register is chosen with a double quote: "ayy copies the current line into register a, and "ap pastes it later even after other deletes. :reg lists what is stored where, and shows that every delete in Vim is also a cut.
vimrc basics: a minimal .vimrc
The vimrc basics fit in one line: settings live in ~/.vimrc. Plain Vim started with -u NONE uses shiftwidth=8, noexpandtab, no line numbers and no search highlighting, which is why many people write a config early. This one is short on purpose:
" Minimal .vimrc
set nocompatible
syntax on
filetype plugin indent on
set number
set relativenumber
set expandtab
set shiftwidth=4
set softtabstop=4
set incsearch
set hlsearch
set ignorecase
set smartcase
set backspace=indent,eol,start
set scrolloff=3
nnoremap <Space> :nohlsearch<CR>Loaded with vim -u vimrc.test, Vim reported every option as set, filetype detection:ON plugin:ON indent:ON, and the <Space> mapping in normal mode. relativenumber makes counts easy: the gutter shows that the target is 7 lines down, so 7j gets there. ignorecase with smartcase makes /foo match Foo, while /Foo matches only Foo. Space clears the search highlight.
New settings can be tried the same way, with vim -u file, before they go into the real vimrc. Those vimrc basics carry most people through the first months. Copying someone else's long config wholesale usually brings mappings that override keys you were still learning.
Splits, tabs, and Vim vs nano
:split file opens a second window above, :vsplit file beside. Ctrl-w w moves to the next window and Ctrl-w followed by h j k l moves in that direction. Tab pages are different from tabs in a browser: each one holds a layout of windows. :tabnew opens one, gt and gT cycle through them.
Vim vs nano, compared on the versions tested:
| Property | nano 7.2 | Vim 9.1 |
|---|---|---|
| First use | Type and go; shortcuts shown at the bottom | Needs the mode idea first |
| Save / quit | Ctrl-o / Ctrl-x | :w / :q and friends |
| Search and replace | Regex optional, asks per match | Regex, line ranges, confirm per match |
| Repeating edits | One recorded macro (Alt-:, Alt-;) | ., counts, macros in any register |
| On minimal systems | Often missing | Some vi is usually there |
In Vim vs nano, nano is the better choice for someone who edits a config file twice a year. For anyone who edits text all day, the Vim text editor wins, because each command combines with the others and repeats. The open question is what happens on the next machine: on a container image without either editor, vi may be BusyBox's small clone, where some of the Vim commands above do not exist.
