Vim essentials: 50 cards on modes, motions, operators and macros
Learn Vim from the keyboard up: modes, motions, operators and text objects, search and :s substitutions, registers, macros, visual mode and windows.
Practice now
Study without an account
Scheduled with the default Askesis timings. Progress is saved in this browser.
All 50 cards
- 1Vim’s main modesNormal mode for commands and moving around, Insert mode for typing text, Visual mode for selecting, and Command-line mode for
:commandsVim starts in Normal mode. - 2How do you get back to Normal mode?Press
Esc(orCtrl-[) - 3
ivsaistarts inserting before the cursor;astarts inserting (appending) after it - 4Start inserting at the beginning or the end of the line
Iinserts before the first non-blank character of the line;Aappends at the end of the line - 5
ovsOoopens a new line below the cursor and enters Insert mode;Oopens one above - 6
:w,:q,:wqand:q!Write (save); quit; write and quit; quit and throw away unsaved changesZZ(like:x) saves only if there are changes, then quits. - 7Quit every window at once, discarding all changes
:qa!:wqasaves every changed buffer and quits instead. - 8
h,j,k,lMove left, down, up and right - 9
w,b,ewmoves to the start of the next word,bback to the start of the current or previous word, andeto the end of the current or next word - 10
wvsWwmoves by words, where a run of punctuation counts as a separate word;Wmoves by WORDs, which are any characters up to the next whitespaceOnfoo.bar(x),wstops at., thenbar, then(, whileWjumps past all of it. - 11
0,^and$The first column of the line, the first non-blank character, and the end of the line - 12
ggandGgggoes to the first line andGto the last;42Gor:42goes to line 42 - 13
fvstfxmoves onto the nextxon the line;txstops just before it.FandTsearch backward;repeats the lastf/tsearch and,repeats it in the opposite direction. - 14What does
%do?Jumps to the matching bracket:(and),[and], or{and} - 15How do counts work with motions?A number before a motion repeats it:
3wmoves three words and5jfive lines downCounts work with operators too:d3wdeletes three words. - 16
Ctrl-dandCtrl-uScroll half a screen down and half a screen upCtrl-fandCtrl-bscroll a full screen forward and back. - 17How do operators combine with motions?An operator such as
d(delete),c(change) ory(yank, which copies) followed by a motion acts on the text the motion covers:dwdeletes to the next word,c$changes to the end of the line - 18
dd,ccandyyDoubling an operator makes it act on the whole line: delete the line, change the line, copy the line - 19
DandCDelete or change from the cursor to the end of the line, the same asd$andc$ - 20
xvsrxdeletes the character under the cursor;rfollowed by a character replaces it without leaving Normal mode - 21
pvsPpputs (pastes) after the cursor, or below the line for whole lines;Pputs before the cursor, or above the line - 22Swap the current line with the one below
ddp: delete the line, then put it below the next one - 23What does
dt,do?Deletes from the cursor up to, but not including, the next comma on the line - 24Undo and redo
uundoes the last change;Ctrl-rredoes it - 25What does
.do?Repeats the last change, such as adw, aciwwith what you typed, or anA;Combined withnit gives a quick search-and-change loop: change once, thenn.to repeat. - 26What are text objects?Selections you use after an operator or in Visual mode:
i(inner) takes just the contents,a(“a”) includes the surrounding whitespace, quotes or brackets - 27
ciwvscawciwchanges the word under the cursor;cawalso takes the whitespace around it, usually the space after the wordBoth work anywhere in the word, unlikecw, which starts at the cursor. - 28What does
ci"do?Changes the text between the double quotes and keeps the quotes; if the cursor is before them, it uses the next quoted string on the line - 29Delete everything inside the curly braces around the cursor
di{(ordi})da{deletes the braces too. The same works with(,[and<. - 30What does
citdo?Changes the text inside the HTML or XML tag around the cursor, keeping the tags - 31What does
dapdo?Deletes the paragraph around the cursor, together with the blank lines after it - 32
/patternvs?pattern/searches forward and?backward;njumps to the next match in the same direction,Nin the opposite one - 33
*and#Search forward or backward for the whole word under the cursor - 34Search without matching caseAdd
\cto the pattern for one search, as in/\cerror, or run:set ignorecase smartcaseto ignore case unless the pattern contains a capital letter - 35Replace every “foo” with “bar” in the whole file
:%s/foo/bar/g%is the range for every line; withoutgonly the first match on each line is replaced. - 36The
g,candiflags of:sgreplaces every match on a line,casks you to confirm each one,iignores case - 37Limit a substitution to some lines
:s/a/b/changes only the current line,:5,10s/a/b/glines 5 to 10, and:'<,'>s/a/b/gthe lines of the last Visual selectionPressing:in Visual mode types:'<,'>for you. - 38What is the unnamed register
""?Whered,c,yandxput text by default, and wherepputs it from - 39You yanked a word, then deleted a line. How do you paste the yanked word?
"0p: register 0 holds the last yank, and deletes don’t overwrite it - 40Yank a line into register
aand paste it"ayy, then"apAn uppercase name appends instead:"Ayyadds the line to registera. - 41Copy to the system clipboard
"+y, for example"+yyfor the current line; paste from it with"+pNeeds a Vim built with clipboard support. On X11,"*is the primary selection. - 42Record and play a macro
qastarts recording into registera,qstops, and@aplays it back@@repeats the last macro you played and10@aruns it ten times. - 43List what’s in every register
:registers(or:reg) - 44
v,VandCtrl-vVisual mode by character, by line, and by block (a rectangle of columns) - 45Add the same text at the start of several linesPress
Ctrl-v, extend down withj, pressI, type the text, thenEscThe text appears on every selected line once you pressEsc. - 46Buffer vs window vs tab pageA buffer is a file loaded in memory, a window is a view onto a buffer, and a tab page is a layout of windows
- 47Open another file and switch between buffers
:e fileopens a file,:lslists buffers,:b 2switches to buffer 2, and:bnand:bpgo to the next and previous buffer - 48Split the window and move between the splits
:split(Ctrl-w s) splits horizontally and:vsplit(Ctrl-w v) vertically;Ctrl-w wcycles through windows andCtrl-w h,j,k,lmove in a direction - 49Get Vim’s built-in help on a command
:helpfollowed by the topic, for example:help ddor:help :sRunvimtutorfrom the shell for an interactive lesson. - 50Keep settings across sessionsPut them in
~/.vimrc(or~/.vim/vimrc), one per line, usually without the leading colonvimset number set relativenumber set ignorecase smartcase
Frequently asked questions
Does this deck work for Neovim?
Yes. Neovim keeps Vim’s modes, motions, operators, registers and commands, so the keys on these cards work the same. Its config file lives in ~/.config/nvim/init.vim or init.lua instead of ~/.vimrc.
How do I get out of Vim?
Press Esc to get to Normal mode, then type :q and press Enter. Use :wq to save first, or :q! to throw your changes away.
How should I practice alongside the cards?
Run vimtutor, which comes with Vim, for a hands-on lesson of about half an hour. Then use one new motion or text object a day in real editing until it becomes a habit.
More in IT & DevOps
Linux command line
Linux commands and files for sysadmins and LPIC-1 candidates: find and grep, permissions and special bits, fstab, systemd targets, package managers, users, cron and more.
50 cardsLinux filesystem basics
Learn the Linux directory tree: what /etc, /var, /usr, /proc and /dev are for, plus passwd, shadow, fstab and hosts. Free flashcards, no signup.
50 cardsIntermediate Linux filesystem
Linux paths admins use daily: /usr/local, /var/lib, /run, /sys, /etc/skel, sudoers, Bash startup files, SSH keys, resolv.conf and /proc. Free flashcards.
50 cardsAdvanced Linux filesystem
Deeper Linux files for LPIC-1: profile.d, sudoers.d, systemd units, GRUB config, nsswitch.conf, ld.so.conf, distro logs and /lib/modules. Free flashcards.
50 cardsBash scripting
Bash scripting flashcards: shebangs, quoting, exit codes, tests, loops, functions, arrays, parameter expansion, redirection, set -euo pipefail and traps.
50 cardsNetworking
Computer networking fundamentals: OSI and TCP/IP layers, TCP vs UDP, common port numbers, subnetting and CIDR, DNS, DHCP and ARP, and IPv6 basics.
50 cardsCyber security
Cyber security flashcards: the CIA triad, phishing, XSS, CSRF, SQL injection, MITM, hashing vs encryption, TLS, MFA, least privilege, OWASP and zero trust.
50 cardsDocker
Learn Docker from images and layers to multi-stage builds, volumes, networks and Compose, with the commands and best practices you use daily.
50 cardsKubernetes
Kubernetes fundamentals for developers and CKA or CKAD candidates: Pods, Deployments, Services, storage, probes, resources and scheduling, plus the kubectl commands you use daily.
50 cardsAWS
AWS flashcards: regions and AZs, EC2, S3 storage classes, IAM users, roles and policies, VPC networking, RDS, Lambda, CloudWatch and Route 53.
50 cardsTerraform
Terraform flashcards: HCL, providers, resources, variables and outputs, state and remote backends, plan and apply, modules, count, for_each, drift and import.
50 cards