Vim Keyboard Shortcuts (Complete Cheat Sheet)

Vim keyboard shortcuts allow users to perform complex text editing tasks in the Vi IMproved editor entirely through a keyboard interface. This page covers 58 verified shortcuts for Windows 10, Windows 11, macOS Sonoma, and Linux systems. Use these Vim hotkeys to switch modes, navigate files, and manipulate text efficiently in terminal environments.

Vim Navigation Shortcuts and Modes

Vim operates using specific modes that change how the software interprets keyboard input. Normal mode allows for navigation and command execution, while Insert mode enables text entry. Understanding these Vim keybinds is the first step toward mastering the editor.

Shortcut / Key CombinationAction / FunctionNotes
iEnter Insert modePlaces the cursor before the current position
aEnter Insert mode (Append)Places the cursor after the current position
EscReturn to Normal modeCancels current command or exits Insert mode
vEnter Visual modeAllows for character-based text selection
V (Shift+V)Enter Visual Line modeSelects entire lines of text
hMove cursor leftMove one character to the left
jMove cursor downMove one line down
kMove cursor upMove one line up
lMove cursor rightMove one character to the right
0 (Zero)Jump to start of lineMoves cursor to the very first character
$Jump to end of lineMoves cursor to the final character of a line
wJump forward one wordMoves to the start of the next word
bJump backward one wordMoves to the start of the previous word
G (Shift+G)Jump to end of fileMoves cursor to the last line of the document
ggJump to start of fileMoves cursor to the first line of the document

Users often pair these with Linux terminal shortcuts to manage configuration files.

Vim Shortcuts for Editing and Text Manipulation

Editing in Vim involves combinations of keys to delete, copy, and paste text. Unlike standard editors, Vim uses a buffer system for these actions. Use the following Vim shortcut keys list to modify text without using a mouse.

Shortcut / Key CombinationAction / FunctionNotes
xDelete current characterRemoves the character under the cursor
ddDelete current lineRemoves the line and saves it to the buffer
dwDelete wordDeletes from the cursor to the end of the word
d$Delete to end of lineDeletes everything from cursor to line end
yyYank (Copy) current lineCopies the line into the temporary buffer
ywYank (Copy) wordCopies the current word into the buffer
pPaste after cursorPlaces buffer content after the cursor
P (Shift+P)Paste before cursorPlaces buffer content before the cursor
uUndo last actionReverts the most recent change
Ctrl+rRedo last actionReapplies a change that was undone
ccChange current lineDeletes the line and enters Insert mode
cwChange wordDeletes the word and enters Insert mode
rReplace single characterSwaps the current character with the next key pressed
J (Shift+J)Join linesMerges the current line with the line below it

How to Save and Exit in Vim

Learning how to exit Vim is a common challenge for new users because the software requires specific command-line inputs. These commands are executed from Normal mode by typing a colon followed by the specific instruction.

Shortcut / Key CombinationAction / FunctionNotes
:wSave the current fileWrites changes to the disk
:qExit VimCloses the editor if no unsaved changes exist
:wqSave and exitWrites changes and closes the editor
😡Save and exitSimilar to :wq but only writes if changes exist
:q!Exit without savingForces the editor to close and discards changes
:waSave all filesWrites changes for all open buffers
:qaClose all filesExits the editor for all open documents

For users working in multi-editor environments, comparing these to Visual Studio Code shortcuts helps clarify different workflow philosophies.

Vim Search and Replace Commands

The Vim keyboard commands for searching allow for rapid movement through large codebases. These commands support regular expressions and global modifiers for document-wide changes.

Shortcut / Key CombinationAction / FunctionNotes
/patternSearch forwardReplace pattern with your search term
?patternSearch backwardSearches upward from the current cursor position
nFind next occurrenceRepeats the search in the same direction
N (Shift+N)Find previous occurrenceRepeats the search in the opposite direction
:%s/old/new/gGlobal replaceReplaces all instances of old with new in the file
:%s/old/new/gcGlobal replace with confirmPrompts for confirmation before each replacement
:nohClear search highlightingRemoves the visual highlight from search results
*Search for word under cursorFinds the next instance of the current word

Advanced Vim Keyboard Commands for Windows and Linux

Advanced users utilize split windows and tabs to manage multiple files simultaneously. These shortcuts facilitate a more complex development landscape without leaving the terminal.

Shortcut / Key CombinationAction / FunctionNotes
:split filenameOpen file in horizontal splitCreates a horizontal window for the new file
:vsplit filenameOpen file in vertical splitCreates a vertical window for the new file
Ctrl+w+hMove to left windowSwitches focus to the window on the left
Ctrl+w+jMove to window belowSwitches focus to the window below
Ctrl+w+kMove to window aboveSwitches focus to the window above
Ctrl+w+lMove to right windowSwitches focus to the window on the right
:tabnewOpen a new tabCreates a fresh tab for a new file
gtMove to next tabCycles forward through open tabs
gTMove to previous tabCycles backward through open tabs
%Jump to matching bracketMoves between matching (), [], or {}
. (Dot)Repeat last commandExecutes the previous editing command again

Refining these skills is similar to learning Sublime Text keybinds for high-speed coding.

Frequently Asked Questions

How do I exit Vim?

Type :q and press Enter to exit if you have no unsaved changes. Use :q! to exit without saving or :wq to save your progress and exit.

What is the undo shortcut in Vim?

Press the u key while in Normal mode to undo your last action. To redo an action that you previously undid, press Ctrl+r.

How do I search for text in Vim?

Press the / key in Normal mode followed by the text you want to find. Press Enter to jump to the first result and use n to cycle through subsequent matches.

How do I copy and paste in Vim?

Press yy to copy a full line or y in Visual mode to copy selected text. Press p to paste the copied content after the cursor.

How do I delete a line in Vim?

Press dd while in Normal mode to delete the entire line where the cursor is currently located. This action also copies the deleted line to the buffer for pasting.

To improve your speed, combine a number with a command, such as typing 3dd to delete three lines at once.

One relevant follow-up question to guide the conversation forward: Are you looking for specific Vim configuration tips, such as how to remap the Caps Lock key to Escape for faster mode switching?