// CHEATSHEETS

THE VIM CHEATSHEET

From [ CrackedVim ] - an interactive VIM course.

/
~/cheatsheets/modes.txt 18 cmds

Modes

Return to normal mode from anywhere
Same as Esc, easier on the pinky
Insert mode at cursor
Insert at first non-blank of line
Insert after cursor (append)
Insert at end of line
Open new line below and insert
Open new line above and insert
Delete char and insert (substitute)
Delete line and insert
Visual mode (character-wise)
Visual line mode
Visual block mode (column edits)
Replace mode (overtype)
Command-line / ex mode
Enter Ex mode (rarely useful, vi <C-c> to exit)
Reselect last visual selection
Insert at the last insert location
~/cheatsheets/motions.txt 33 cmds

Cursor motions

Left, down, up, right
Next word start (punctuation breaks words)
Next WORD start (whitespace separated)
Next word end
Next WORD end
Previous word start
Previous WORD start
Previous word end
Previous WORD end
Start of line (column 0)
First non-blank character of line
End of line
Last non-blank character of line
First column; with count goes to that column
Top of file
Bottom of file
Jump to line n
Same as {n}G via command line
Jump to matching bracket / paren / brace
High: top of visible screen
Middle of visible screen
Low: bottom of visible screen
Center current line on screen
Scroll current line to top
Scroll current line to bottom
Half page down
Half page up
Full page down
Full page up
Previous blank-line paragraph
Next blank-line paragraph
Previous sentence
Next sentence
~/cheatsheets/find-line.txt 6 cmds

Find on the current line

Jump to next x on this line
Jump to previous x on this line
Jump to before next x
Jump to after previous x
Repeat last f / F / t / T forward
Repeat last f / F / t / T backward
~/cheatsheets/operators.txt 17 cmds

Operators

Delete (cuts to register)
Change: delete then enter insert
Yank (copy)
Auto-indent over motion
Indent right
Indent left
Lowercase
Uppercase
Toggle case
Format / wrap text via formatprg
Paste after cursor
Paste before cursor
Paste and leave cursor after pasted text
Paste before, cursor after pasted text
Delete line
Yank line
Change whole line
~/cheatsheets/text-objects.txt 24 cmds

Text objects

Inner word
A word (with surrounding whitespace)
Inner WORD
A WORD
Inner sentence
A sentence
Inner paragraph
A paragraph
Inside double quotes
Around double quotes
Inside single quotes
Around single quotes
Inside backticks
Around backticks
Inside parentheses
Around parentheses
Inside brackets
Around brackets
Inside braces
Around braces
Inside angle brackets
Around angle brackets
Inside HTML / XML tag
Around HTML / XML tag (includes the tags)
~/cheatsheets/edits.txt 14 cmds

Edits and small changes

Delete character under cursor
Delete character before cursor
Replace single character with c
Enter replace mode (overtype)
Substitute char (delete + insert)
Substitute line
Toggle case of character
Join line below into current with a space
Join without inserting a space
Undo
Redo
Undo all changes on current line
Repeat last change
Repeat last ex command
~/cheatsheets/visual.txt 14 cmds

Visual mode

Start character-wise visual
Start line-wise visual
Start block-wise visual
Toggle anchor end of selection
Toggle anchor corner in block visual
Reselect last visual range
Extend to a / inside word
Extend to a / inside paragraph
Block-insert text on each line of block visual
Block-append text on each line of block visual
Block-change replaces text on each line
Toggle case of selection
Lowercase selection
Uppercase selection
~/cheatsheets/registers.txt 13 cmds

Yank, paste, registers

Yank into register a
Paste from register a
Yank into system clipboard
Paste from system clipboard
Yank into selection clipboard (X11)
Paste last yank (survives deletes)
Delete into the black hole register
The unnamed (default) register
Current file path register (read-only)
Last ex command (read-only)
Last search pattern (read-only)
Show all registers
Show only registers a and b
~/cheatsheets/substitute.txt 12 cmds

Search and replace

Replace first foo on current line
Replace all foo on current line
Replace all foo in file
Replace all in file with confirm
Replace all, force case sensitive
Reuse last search pattern as the search
Replace within last visual selection
Repeat last :s with same flags
Repeat last :s on current line, no flags
Repeat last :s on whole file with same flags
Goto local declaration of word
Goto global declaration of word
~/cheatsheets/buffers.txt 9 cmds

Buffers

List open buffers
Switch to buffer by number or name
Next buffer
Previous buffer
Delete (close) current buffer
Force delete buffer (discard changes)
Run cmd in every buffer
Switch to alternate (last) buffer
Toggle to alternate buffer
~/cheatsheets/windows.txt 15 cmds

Windows

Vertical split
Horizontal split
Move focus left / down / up / right
Close current window
Close all other windows
Equalize window sizes
Increase window height
Decrease window height
Increase window width
Decrease window width
Rotate windows down / right
Rotate windows up / left
Swap current window with next
Move current window to its own tab
Cycle to next window
~/cheatsheets/tabs.txt 9 cmds

Tabs

Open a new tab
Open file in new tab
Close current tab
Close all other tabs
Next tab
Previous tab
Next tab (normal mode)
Previous tab (normal mode)
Jump to tab n
~/cheatsheets/marks.txt 14 cmds

Marks and jumps

Set local mark in current buffer
Set global mark across files
Jump to line of mark
Jump to exact column of mark
Jump to line before last jump
Jump to position before last jump
Position of last change
Position of last insert
Start / end of last yank or change
Older position in jumplist
Newer position in jumplist
List marks
List the jumplist
Delete marks
~/cheatsheets/changes.txt 3 cmds

Change list

Older position in change list
Newer position in change list
List the change list
~/cheatsheets/macros.txt 7 cmds

Macros

Start recording into register a
Stop recording
Replay macro from register a
Replay last replayed macro
Replay macro a, n times
Inspect macro recorded in a
Append to existing macro a
~/cheatsheets/folds.txt 9 cmds

Folds

Open fold under cursor
Close fold under cursor
Toggle fold under cursor
Open all folds in file
Close all folds in file
Move to next fold
Move to previous fold
Manually create a fold over motion
Delete fold under cursor
~/cheatsheets/indent.txt 8 cmds

Indentation

Indent line right
Indent line left
Indent over motion right
Indent over motion left
Auto-indent over motion
Auto-indent from cursor to end of file
Auto-indent the paragraph
Auto-indent the entire file
~/cheatsheets/insert.txt 19 cmds

Insert-mode tricks

Delete word before cursor
Delete to start of line
Backspace
Indent current line right
Indent current line left
Insert char above cursor
Insert char below cursor
Insert contents of register
Insert result of an expression
Next keyword completion
Previous keyword completion
File path completion
Whole-line completion
Omni completion (LSP-like)
Buffer keyword completion
Dictionary completion
Spelling suggestion completion
Run one normal-mode command then return
Trigger abbreviation expansion
~/cheatsheets/cmdline.txt 21 cmds

Command line and ex

Write file
Write to a different file
Quit window
Write and quit
Write if changed and quit
Quit and discard changes
Quit all windows
Write all changed buffers
Open / reload a file
Discard changes and reload current file
Save as (and switch to) new file
Read file into current buffer
Read shell command output into buffer
Run shell command
Sort lines (range or whole file)
Sort selection, remove duplicates
Run cmd on every matching line
Run cmd on every NON-matching line
Delete every line matching pat
Open command-line history window
Open search history window
~/cheatsheets/quickfix.txt 13 cmds

Quickfix and location list

Open the quickfix window
Close the quickfix window
Next quickfix entry
Previous quickfix entry
First quickfix entry
Last quickfix entry
Run cmd on each quickfix entry
Open the location list (window-local)
Close the location list
Next location entry
Previous location entry
Populate quickfix with grep results
Use vim-native grep
~/cheatsheets/spell.txt 8 cmds

Spelling

Turn spell checker on
Turn spell checker off
Next misspelled word
Previous misspelled word
Show spelling suggestions
Add word to dictionary
Mark word as wrong
Undo zg / zw for word
~/cheatsheets/misc.txt 15 cmds

Productivity miscellany

Open URL under cursor with system handler
Open file path under cursor
Open file path under cursor + line number
Look up word under cursor in man pages
Toggle to alternate buffer
Show file name and cursor position
Show byte / word / line / char count
Show character code (decimal, hex, octal)
Show UTF-8 byte sequence under cursor
Reselect last visual range
Older position in change list
Newer position in change list
Write file and quit (= :x)
Quit without writing (= :q!)
Redraw the screen
~/cheatsheets/philosophy.txt 5 cmds

The dot-repeat philosophy

Repeat the last change. Compose so each edit is one undoable, repeatable change.
Find next match, then repeat the change. Poor-mans search and replace.
After f / t, jump and repeat. Powerful inside a single line.
Change next search match; then `.` repeats and advances. The cleanest replace pattern.
Repeat last ex command.