Skip to content

Vim Motions Explained

The Vim keystrokes used day to day, grouped by job: move around, edit text, select, record macros, drop marks, search and replace, save and quit, and manage splits, tabs, and files. Each row pairs the keys with what they do.

Vim is a modal editor: you are either inserting text or issuing commands, never both at once. Press Esc to leave insert mode and return to normal mode, where every key is a command. The payoff is that common edits become short sequences you type without reaching for the mouse or menus. The commands below assume you are in normal mode unless a row says otherwise.

Reference table · 65 entries
65 of 65 rows
Moving around
Move the cursor left, down, up, right one cell.
Jump to the next word start, previous word start, or end of the current word.
Jump to the first or last character of the line.
Jump to the first or last line of the file.
Scroll half a page down or up.
Jump to the next or previous occurrence of character x on the line.
Jump to just before the next, or just after the previous, occurrence of character x.
Repeat the last f, F, t, or T jump in the same or the opposite direction.
Jump to the bracket, brace, or parenthesis that matches the one under the cursor.
Jump to the previous or next blank line (a paragraph boundary).
Jump to the start of the previous or next sentence.
Jump to the top, middle, or bottom line of the visible window.
Redraw so the cursor line sits at the center, top, or bottom of the window.
Jump back or forward through the list of positions you jumped from.
Return to the position of the last insert and start inserting again.
Editing
Enter insert mode before or after the cursor.
Enter insert mode at the start or end of the line.
Open a new line below or above and start inserting.
Delete the line, the next word, or the character under the cursor.
Change (delete and insert) the line or the next word.
Clear the current line and start inserting (same as cc).
Delete, change, or yank from the cursor to the end of the line (Y yanks the whole line).
Change, delete, or select the word under the cursor from anywhere inside it.
Target the inside of quotes, parentheses, braces, a paragraph, or a tag pair with c, d, or v.
Delete or change up to just before the next occurrence of character x.
Join the next line onto the current one.
Shift the selected lines right or left by one indent level.
Replace the character under the cursor, or overwrite characters as you type.
Toggle, lower, or upper-case the character under the cursor or the selection.
Swap the character under the cursor with the next one (delete then paste).
Paste the deleted or yanked text after or before the cursor.
Undo or redo the last change.
Repeat the last change at the cursor.
Visual selection
Start character-wise selection; move to extend.
Start line-wise selection.
Start block (column) selection.
Re-select the most recent visual selection.
Macros & registers
Record keystrokes into register a; press q again to stop.
Play the macro stored in register a, or replay the last macro played.
Yank into register a instead of the default unnamed one.
List every register and its current contents.
Marks
Set mark a at the current cursor position.
Jump to mark a; the backtick lands on the exact spot, the quote on the start of its line.
Jump to the start or end of the most recent visual selection.
Search & replace
Search forward or backward for a pattern.
Jump to the next or previous match.
Search forward or backward for the word under the cursor.
Replace every old with new across the whole file (the gc form asks before each change).
Clear the highlighting left by the last search.
Delete every line that matches the pattern.
Sort the selected lines, or the whole file with a % range.
Saving & quitting
Write (save) the file.
Quit; add ! to force (discard unsaved changes).
Write the file and quit.
Write-and-quit or quit-without-saving, no command line needed.
Splits & windows
Split the window horizontally or vertically.
Move the cursor to the split left, down, up, or right.
Equalize the size of all splits.
Close the current split.
Tabs & files
Open a file in the current window, or reload it from disk with no name.
Browse and open files from a listing inside the current window.
Open a new tab, then move to the next or previous one.
Save the current windows, tabs, and marks to a session file.
Turn on line numbers, relative line numbers, and search highlighting.
Run a shell command and return to the buffer.