Tutorial
Vim Tutorial
A practical tutorial on Vim, from modes and motions to the editing habits that make the editor feel like an extension of your hands. Covers the modal model, text objects, registers and macros, buffers and windows, configuration, plugins, and the idioms that separate fluent users from survivors.
Chapters
01
Introduction: What Vim Is and Why Anyone Uses It
02
Modes: The Mental Model That Makes Vim Make Sense
03
Navigation: Moving Without Touching the Arrow Keys
04
Editing: Operators, Counts, and the Dot Command
05
Text Objects: The Grammar Multiplier
06
Search and Replace: Finding Things and Changing Them
07
Buffers, Windows, Tabs: Vim's Three Kinds of Container
08
Registers and Macros: 26 Clipboards and a Record Button
09
Configuration: Writing a .vimrc You Won't Be Embarrassed By
10
Plugins: The Short List Worth Installing
11
Advanced Techniques: Folds, Marks, Quickfix, Completion, Terminal
12
Best Practices: Idioms, Habits, and Knowing When to Step Out
About this tutorial
A practical tour of Vim, from your first :q! to the editing habits that make the editor feel like an extension of your hands.
Who This Is For
- Developers who know a terminal and want an editor that stops getting in the way
- Engineers who already use Vim "a little" and want to stop fighting it
- Anyone who has watched someone fluent in Vim and thought "I want that"
Contents
Fundamentals
- Introduction: What Vim is, installing it, surviving
vimtutor, opening and saving your first file - Modes: Normal, insert, visual, command-line, operator-pending, and the mental model that ties them together
Core Concepts
- Navigation: hjkl, word and line motions, screen motions, the jump list,
ggandG - Editing: Operators (
d,c,y,p), counts, the dot command, undo and redo - Text Objects:
iw,aw,i",a(,i{, composing operators with motions and objects - Search and Replace:
/,?,*,n,N,:substitute,:global, very-magic mode
Advanced
- Buffers, Windows, Tabs:
:e,:b,:sp,:vsp, window navigation, tab pages - Registers and Macros: Named registers, the system clipboard,
qto record,@to replay - Configuration:
.vimrc,:set, mappings, autocommands, the leader key
Ecosystem
- Plugins: Native packages, vim-plug, the handful of plugins worth installing, a brief Neovim and LSP note
- Advanced Techniques: Folds, marks in depth, quickfix and location lists, completion, terminal mode
Mastery
- Best Practices: Idioms, muscle-memory patterns, anti-patterns, knowing when to step out of Vim
How to Use This Tutorial
- Read sequentially for a complete learning path
- Type out the commands. Watching someone else use Vim teaches you nothing
- Keep a scratch file open while reading. Break it, reload it, try things
Quick Reference
Essential Commands
# Open and close
vim notes.md # open a file
:w # save
:q # quit
:wq # save and quit
:q! # quit, discard changes
# Move (normal mode)
h j k l # left down up right
w b e # next word, previous word, end of word
0 ^ $ # start of line, first non-blank, end of line
gg G # top of file, bottom of file
# Edit
i a o # insert before, after, new line below
x dd yy p # delete char, delete line, yank line, put
u <C-r> # undo, redo
. # repeat last change
# Search
/pattern # search forward
n N # next, previous match
:%s/old/new/g # replace in whole file
Your First Session
vim scratch.txt
# press i to enter insert mode, type a few lines
# press <Esc> to return to normal mode
# type :w<Enter> to save
# type :q<Enter> to quit
Common Patterns
ciw change inner word
ci" change inside quotes
dap delete a paragraph (and the blank line after)
>ap indent a paragraph
gUiw uppercase inner word
"+yy yank line to system clipboard
:%s/foo/bar/gc replace with confirmation
qa...q @a record macro in register a, replay
Learning Path Suggestions
Survive your first week (roughly 4 hours)
- Chapter 01 and 02 for orientation and the modal model
- Chapter 03 for motions you will use every minute
- Chapter 04 for the operator mental model (
d,c,y,p,.) - Use Vim for a day with nothing else
Get fluent (roughly 8 hours)
- Chapter 05 on text objects (the grammar multiplier)
- Chapter 06 on search and substitute
- Chapter 07 on buffers and windows
- Chapter 08 on registers and macros
Make Vim yours (roughly 4 hours)
- Chapter 09 to write a lean
.vimrc - Chapter 10 to add a few plugins
- Chapter 12 to learn which habits to lean on
Why Vim?
- Modal editing. Most of your time is not typing new text, it is moving and changing existing text. Vim optimises for that
- Composable commands.
d+ motion,c+ motion,y+ motion. Learn a few operators and a few motions and you get their product for free - Everywhere. SSH into a box, and Vim is already there. Most IDEs have a Vim mode worth turning on
- Longevity. Vim has been stable for decades. Skills transfer
Additional Resources
- Vim official docs (the
:helpsystem, online and searchable) - Practical Vim by Drew Neil (the book to read)
- vimtutor (ships with Vim, run
vimtutorin your terminal) - Vim Adventures (learn motions as a game)
- Neovim (modern fork with Lua config and first-class LSP)
- vim-plug (the most common plugin manager)
Vim Version
This tutorial is written for Vim 9+ and uses commands available in Vim 8.2 or later. Most examples apply equally to Neovim 0.9+, and differences are called out where they matter.