VimFu
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 printed book goes deeper — history, internals, mental models, and worked examples for every concept. The site is the cheat sheet; the book is the why.
โถ Open the simulator An in-browser Neovim + tmux for practicing anything you read here.
Contents
Foundations
- 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
- 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
- Undo and Redo โ u to undo. Ctrl-R to redo. You cannot lose work.
- Move with hjkl โ h left, j down, k up, l right โ without leaving home row
Basic Editing
- 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{char} โ overwrite one character without entering Insert mode.
Search Find
- Pattern Search โ / searches forward, ? searches back. n and N step through matches.
- Word Search โ * / # โ search for the word under the cursor without typing it.
- Find on Line โ f, F, t, T โ jump to a character without leaving the line.
Counts Visual
- 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.
- Character Visual Mode โ v โ select first, act second.
- Line and Block Visual โ V selects whole lines. Ctrl-V selects rectangles.
- Visual Mode Tricks โ Block O for diagonal corners. gv to re-select.
Dot Repeat
- Repeat Last Change โ . โ replay the last change. The single most useful key.
- Dot with Counts โ {n}. โ replay the change with a new count.
- Dot Patterns โ Search + change + dot. The two main refactor idioms.
Operators Textobjects
- Inner Word vs A Word โ iw and aw โ the first text objects.
- 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}
Wider Motions
- 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 Screen
- 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.
- z. / z+ / z- โ Scroll and Land on First Non-Blank โ Like zz/zt/zb, but the cursor jumps to the first non-blank.
- z{n}Enter โ Set Window Height โ Resize the current window to {n} lines, scroll cursor's line to the top.
- Line-by-Line Scroll โ Ctrl-E and Ctrl-Y โ scroll without moving the cursor (until you have to).
- Horizontal Scroll โ zs, ze, zh, zl โ scroll left/right when wrap is off.
Marks Jumps
- 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 โ ' jumps to the line of a mark. ` jumps to the exact position.
- 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
- Replace Mode โ R โ overwrite as you type. r{c} โ overwrite one character.
- 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
- 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 โ "0 = last yank. "1โ"9 = the last nine deletes.
- 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
- 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 Tabs
- Creating Splits โ Ctrl-W s โ horizontal split. Ctrl-W v โ vertical.
- 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 :ls and :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
- 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
- Exiting Insert Mode โ Three ways out, and why people remap.
- One-Shot Normal Mode โ Ctrl-O runs one Normal command without leaving Insert.
- 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) โ Vim has had autocomplete since 1996.
- 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
- 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 โ :sort with flags handles unique, numeric, reverse, and key-based sorting.
Visual Depth
- 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.
- gv โ Re-Select โ Bring back the last visual selection.
Command Line Power
- 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 Recipes
- Swap and Duplicate Lines โ ddp swaps two lines. yyp duplicates one.
- *, cw, then . . . โ The Replace Loop โ Search a word, change one, repeat with dot.
- cgn โ Change-Next-Match Loop โ 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
- Undo as a Tree โ g- and g+ walk by time. :undolist shows the branches.
- Special Registers Deep Dive โ %, #, :, ., /, =, _ โ the read-only and computed ones.
- Operator-Pending Mode โ The fourth mode you didn't know about.
- Terminal Inside Vim โ :terminal opens 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
- 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.
- Surround (the Plugin That Should Be Built In) โ ds, cs, ys โ operate on surroundings as a first-class concept.
- Vim in Other Editors โ VS Code, JetBrains, browsers โ you can take it with you.
- Complete Key Reference โ Every Normal-mode key, in one place.