Skip to content

vim

Essential Vim shortcuts for navigation, selecting text, editing and more.

Navigation

Move efficiently within a file using these commands.

Move to beginning of line

Jumps to the first character of the current line.

0

Move to end of line

Jumps to the last character of the current line.

SHIFT + 4

Move to a specific line

Jumps to a specified line number.

:[line number] + ENTER

Move forward one word

Jumps to the beginning of the next word.

w

Move backward one word

Jumps to the beginning of the previous word.

b

Move to matching bracket

Jumps between matching parentheses, brackets, or braces.

%

Tab (add indent)

In insert mode, increases the indentation level.

CTRL + t

Un-tab (remove indent)

In insert mode, decreases the indentation level.

CTRL + d

Selecting Text

Commands for selecting, deselecting, and highlighting text, lines, or the entire file.

Select text

Starts visual mode to select text character by character.

v
Use arrow keys to expand selection.

Select line

Selects entire lines instead of characters.

V
Use up/down to extend selection by lines.

Select entire file

Selects all text in the file.

ggVG

Deselect selection

Exits visual mode and clears selection.

ESC

Editing

Modify text with these essential Vim commands.

Insert mode

Enters insert mode to start typing.

i or a
i=insert before cursor, a=append after cursor

Escape insert mode

Escapes the insert mode.

ESC

Replace a character

Replaces the character under the cursor.

r + [new character]

Change a word

Deletes the word under the cursor and enters insert mode.

caw

Delete a character

Deletes the character under the cursor.

x

Delete a word

Deletes the word under the cursor.

daw

Copy

Copies the selected text or the current line.

y or yy
y=selected text, yy=current line

Cut

Cuts the selected text or the current line.

d or dd
d=selected text, dd=current line

Paste

Pastes the last cut or copied text at the cursor position.

p or P
p=after cursor, P=before cursor

Copy to system clipboard

Copies the selected text or current line to the system clipboard.

"+y or "+yy
"+y=selected text, "+yy=current line

Cut to system clipboard

Cuts the selected text or current line to the system clipboard.

"+d or "+dd
"+d=selected text, "+dd=current line

Paste from system clipboard

Pastes text from the system clipboard into Vim.

"+p or "+P
"+p=after cursor, "+P=before cursor

Undo last change

Reverts the last edit.

u

Redo last undone change

Reapplies the last undone change.

CTRL + r

Search and Replace

Find text and perform replacements efficiently.

Search for a word

Finds the next occurrence of a word in the file.

/word + ENTER

Search backward for a word

Finds the previous occurrence of a word in the file.

?word + ENTER

Repeat last search

Moves to the next match of the last search.

n or N
n=forward, N=backward

Replace text globally

Replaces all occurrences of a word with another in the whole file.

:%s/old/new/g + ENTER

Replace text in the current line

Replaces all occurrences of a word in the current line.

:s/old/new/g + ENTER

Exiting Vim

How to quit Vim safely.

Save and exit

Writes changes to file and quits.

:wq + ENTER

Quit without saving

Exits Vim without saving changes.

:q! + ENTER

Save without exiting

Saves the file but stays in Vim.

:w + ENTER

Windows and Tabs

Manage multiple files and workspaces.

Open a new tab

Opens a new tab in Vim.

:tabnew + ENTER

Switch between tabs

Moves to the next or previous tab.

gt or gT
gt=next, gT=previous

Split window horizontally

Splits the window into two horizontal panes.

CTRL + w + s

Split window vertically

Splits the window into two vertical panes.

CTRL + w + v

Switch between windows

Moves the cursor between split windows.

CTRL + w + [arrow key]

Miscellaneous

Other useful Vim commands.

Show line numbers

Displays line numbers in the editor.

:set number + ENTER

Hide line numbers

Hides line numbers in the editor.

:set nonumber + ENTER

Enable syntax highlighting

Turns on syntax highlighting.

:syntax on + ENTER

Disable syntax highlighting

Turns off syntax highlighting.

:syntax off + ENTER