The Vim & Neovim reference for programmers — companion to the book.
This is the online reference half of VimFu. Quick to scan, deep-linkable, packed with embedded videos. Every topic in the book has a page here so you can look something up without flipping pages.
The site is the cheat sheet; the book is the why.
โถ Open the simulator ๐ฌ All videos An in-browser Neovim + tmux for practicing anything you read here.
Contents
Foundations ๐ฌ videos
- Modal Editing โ Why every key on the keyboard is a command
- The Modes โ A small finite state machine you carry in your head
- The Universal Grammar โ [count] [register] operator [count] motion
- You Don't Need Vim โ Vim keybindings work in almost every editor and IDE
viโ Vim โ Neovim โ Fifty years of an editing language
Survival ๐ฌ videos
- Open, Save, Quit โ Launch Neovim, write your work, and get out โ three ways each
- Insert and Back Again โ i to type, Esc to come home
- Move with hjkl โ h left, j down, k up, l right โ without leaving home row
- Undo and Redo โ u to undo. Ctrl-R to redo. You cannot lose work.
- Undo as a Tree โ g- and g+ walk by time.
:undolistshows the branches.
Basic Editing ๐ฌ videos
- More Ways into Insert โ Five doors into insert mode โ pick the one that lands the cursor where you want.
- Word Motions โ Move a word at a time. The grammar's first real noun.
- Line Motions โ 0 / ^ / $ โ the three places that matter on a line.
- File Motions โ gg, G, {n}G โ jump anywhere in the file.
- Delete โ d is the verb. Pair it with any motion.
- Change โ c is delete-then-insert, atomically.
- Yank and Put โ Yank is copy. Put is paste. The register knows whether it's a line or a span.
- Replace a Character โ r{c} โ overwrite one character without entering insert mode.
- Replace Mode โ R โ overwrite as you type. r{c} โ overwrite one character.
Search and Find ๐ฌ videos
- Pattern Search โ Jump to any text in the buffer, then keep going with one keystroke.
- Word Search โ * / # โ search for the word under the cursor without typing it.
- Find on Line โ Single-line jumps that never disturb your row.
Counts ๐ฌ videos
- Counts โ Type a number before any motion or operator. It multiplies.
- Percentage and Column Jumps โ {n}% jumps to a percentage of the file. {n}| jumps to a column.
Dot Repeat ๐ฌ videos
- Repeat Last Change โ . โ replay the last change. The single most useful key.
- Dot with Counts โ Dot lets you change your mind about the count.
- Dot Patterns โ Search + change + dot. The two main refactor idioms.
Text Objects ๐ฌ videos
- Inner Word vs Around Word โ Name a chunk of text directly instead of motioning to its ends.
- Quote Text Objects โ i" / a" / i' / a' โ operate on a quoted string without finding its boundaries.
- Bracket Text Objects โ i( i{ i[ i< โ operate on the contents of any bracket pair.
- Sentence and Paragraph โ is / as / ip / ap โ for prose.
- HTML/XML Tag Objects โ it / at โ operate inside an HTML or XML tag pair.
- The Vim Grammar โ [count] [register] operator [count] {motion | text-object}
- Operator-Pending Mode โ The fourth mode you didn't know about.
- Surround โ ds, cs, ys โ operate on surroundings as a first-class concept.
Wider Motions ๐ฌ videos
- Sentence and Paragraph Motions โ ( ) โ sentences. { } โ paragraphs.
- Match Bracket โ % โ jump to the matching paren, brace, or bracket.
- Screen Position Jumps โ H, M, L โ High, Middle, Low on the visible screen.
- Line-Start Motions โ +, -, Enter โ jump to first non-blank of next/previous line.
- WORD Motions โ W, B, E, gE โ like w/b/e/ge but bigger words.
Scrolling the Screen ๐ฌ videos
- Half- and Full-Page Scrolling โ Ctrl-D / Ctrl-U / Ctrl-F / Ctrl-B โ scroll without losing place.
- Centering the Cursor โ zz, zt, zb โ move the viewport, not the cursor.
- Scroll and Land on First Non-Blank โ z. / z+ / z- โ Scroll and re-home the cursor in one keystroke.
- Set Window Height โ z{n}Enter โ An obscure but occasionally perfect resize trick.
- Line-by-Line Scroll โ Peek at what's just off-screen without moving the cursor.
- Horizontal Scroll โ zs, ze, zh, zl โ scroll left/right when wrap is off.
Marks and Jumps ๐ฌ videos
- Setting and Jumping to Marks โ m{a-z} sets a mark. '{a-z} jumps to its line. `{a-z} jumps to its exact spot.
- Special Marks โ Marks Vim sets for you automatically.
- Tick vs Backtick โ Two ways to land on the same mark โ line, or exact spot.
- The Jump List โ Ctrl-O / Ctrl-I โ walk back and forward through your big jumps.
- The Change List โ g; / g, โ walk through the places you've been editing.
Transform ๐ฌ videos
- Indent and Auto-Indent โ >> indents. << dedents. ={motion} re-indents using the language indenter.
- Case Changing โ ~ flips one character. gU/gu/g~ are operators.
- Joining Lines โ J joins the next line to the current. gJ joins without a space.
Registers ๐ฌ videos
- Registers โ A dictionary of named clipboards built from one primitive
- The Unnamed Register โ "" โ where every yank and delete lands by default.
- Named Registers โ "aโ"z โ your 26 personal slots. Capitals append.
- Numbered Registers โ The yank-and-delete backlog you didn't know you were keeping.
- The Small Delete Register โ "- โ for charwise deletes that wouldn't be worth a numbered slot.
- System Clipboard Registers โ "+ and "* โ bridge to the OS clipboard.
- Special Registers โ "/ ": ". "% "# "= "_ โ the read-only and weird ones.
- Macros Are Just Register Contents โ "ap โ edit โ "ay$ โ the macro lifecycle as text editing.
Macros ๐ฌ videos
- Recording and Playing Macros โ qa records into register a. q stops. @a plays.
- Counted Macros โ 100@a โ run a macro a hundred times. Or until it errors out.
- Editing a Macro โ Paste it, fix it, yank it back. Macros are text.
Windows, Buffers and Tabs ๐ฌ videos
- Creating Splits โ Open more than one viewport onto the same workspace.
- Navigating Windows โ Ctrl-W h/j/k/l โ move between splits. Ctrl-W c โ close. Ctrl-W o โ only.
- Move and Resize Windows โ Ctrl-W H/J/K/L moves the window. Ctrl-W +/-/</> resizes.
- Buffers โ Files in memory, navigated with
:lsand:b. - Tabs โ
:tabnew, gt, gT โ tabs are layouts of windows, not files. - Buffer vs Window vs Tab โ Three concepts most editors collapse into one. Vim keeps them separate.
Prefix Families ๐ฌ videos
- The g Family โ 30+ commands hide behind the g prefix.
- The z Family โ Folding, scrolling, spell. The most thematically scattered prefix.
- The [ and ] Family โ [ goes back, ] goes forward. The semantic siblings of search.
- The Ctrl-W Family โ 30+ window commands hide behind the Ctrl-W prefix.
Insert Mode Power ๐ฌ videos
- Exiting Insert Mode โ Three ways out, and why people remap.
- One-Shot Normal Mode โ Ctrl-O runs one normal mode command without leaving insert mode.
- Editing Inside Insert Mode โ Ctrl-W, Ctrl-U, Ctrl-H โ readline survivors.
- Indent in Insert Mode โ Ctrl-T and Ctrl-D, plus 0Ctrl-D and ^Ctrl-D.
- Inserting from a Register โ Ctrl-R is paste โ but with a twist.
- Copy Adjacent Lines โ Ctrl-Y and Ctrl-E pull from above and below.
- Word Completion (Ctrl-N / Ctrl-P) โ Type a few letters; let Vim finish the word.
- The Ctrl-X Sub-Completions โ Specialized completion: filenames, lines, dictionary, omni.
- Literal Insert and Digraphs โ Ctrl-V for literals, Ctrl-K for digraphs โ type the un-typeable.
Ex Commands ๐ฌ videos
- File Operations โ
:w,:e,:q,:wq,:xโ and the bangs that mean force. - Substitute (
:s) โ The most powerful single command in Vim. - Ex Ranges โ Every Ex command takes a range. Learn to speak it fluently.
- Global (
:g) and Vglobal (:v) โ "Run a command on every line that matches." - Normal (
:norm) โ Run normal mode keystrokes from Ex. - Shell Commands (
:!) โ Bang sends to the shell. Use as a filter or a one-shot. - Setting Options (
:set) โ How options work, and the conventions you'll see in every vimrc. - Quickfix and Location Lists โ A typed list of file:line:message โ the spine of grep, make, and lint workflows.
- Sort and Reorder Lines โ
:sortwith flags handles unique, numeric, reverse, and key-based sorting.
Visual Modes ๐ฌ videos
- Character Visual Mode โ v โ select first, act second.
- Line and Block Visual โ Two more shapes for the same select-then-act idea.
- Visual-Mode Tricks โ Block O for diagonal corners. gv to re-select.
- The Three Visual Modes โ v, V, Ctrl-V โ character, line, block.
- Block Insert and Append โ I and A in block mode = insert/append on every selected line.
- Swap and Adjust Endpoints โ o jumps to the other end. O switches corners in block mode.
- Operators on Visual Selections โ Any operator works on a Visual range. Plus a few visual-only ones.
- Visual + Ex Range โ Pressing : from Visual auto-fills the range.
- Re-Select โ gv โ Bring back the exact selection you just dismissed.
Command Line Power ๐ฌ videos
- Command-Line History โ โ/โ for prefix-match, q: for the full window.
- Repeat Last Ex (@:) โ @: replays your last
:command. Then @@ repeats again. - Editing the Command Line โ Ctrl-B, Ctrl-E, Ctrl-W, Ctrl-U โ readline-flavored.
- Paste from Buffer (Ctrl-R) โ Same Ctrl-R as insert mode โ inject any register.
- Command-Line Completion โ Tab to complete; Ctrl-D to list.
- The Wildmenu โ
wildmenu,wildmode,wildoptionsโ making Tab at the : prompt actually pleasant.
Patterns and Recipes ๐ฌ videos
- Swap and Duplicate Lines โ ddp swaps two lines. yyp duplicates one.
- The Replace Loop โ *, cw, then . . . โ Search a word, change one, repeat with dot.
- Change-Next-Match Loop โ cgn โ Like *cw, but . jumps and changes in one step.
- Block Comment with Ctrl-V + I โ Add a comment marker to {n} consecutive lines.
- Increment and Decrement (Ctrl-A / Ctrl-X) โ Find the next number, add or subtract โ with counts.
- Walking the Numbered Registers โ "1p, then u and . to walk the cut-history backwards.
- Diff Mode โ vimdiff and
:diffthisโ visualize and edit changes side-by-side. - External Filter Tricks โ !{motion}cmd โ let any Unix tool transform your text.
Advanced ๐ฌ videos
- Special Registers Deep Dive โ %, #, :, ., /, =, _ โ the read-only and computed ones.
- Terminal Inside Vim โ
:terminalopens a real shell โ usable with Vim navigation. - Character Info (ga, g8, g Ctrl-G) โ What is this character? Where am I?
- gx and g< โ Open URLs and recall command output.
- Folding โ Hide regions of text โ manual, syntax, indent, marker.
- Vim Configuration โ vimrc, runtime, plugins โ where settings live.
- Spell Checking โ Built-in spell checker with per-language dictionaries.
- Tag Navigation โ Jump to definitions across files using a tags index.
- Mappings โ
:map,:noremap, and Friends โ How to bind a keystroke to a command in every mode, and what the modifiers actually do.
Tmux ๐ฌ videos
- What Is tmux? โ A terminal multiplexer โ one screen, many sessions
- The Prefix Key โ Every tmux command starts with Ctrl-B (or whatever you remap it to)
- Panes โ Split, Navigate, Resize โ One window, many shells, all visible at once
- Windows โ Like virtual desktops, scoped to one tmux session
- Sessions, Detach, Reattach โ The feature that survives SSH drops and laptop reboots
- Copy Mode โ Vim Motions in Your Scrollback โ Read the buffer, select text, yank it, paste it
Appendices
- Keyboard Walk โ Every normal-mode key, organized by physical key location.
- Synonyms and Shortcuts โ Equivalent commands you'll see in different vimrcs.
- The Grammar Matrix โ Every operator ร every text object = the table that makes Vim click.
- A Suggested Learning Path โ What to learn first, second, third โ and what to ignore until later.
- Motion Classification โ Char-wise vs line-wise vs block, inclusive vs exclusive.
- Vim in Other Editors โ VS Code, JetBrains, browsers โ you can take it with you.
- Complete Key Reference โ Every normal mode key, in one place.
- Complete Options Reference โ All 457 options across Vim and Neovim