Skip to content

vim

Navigation, editing and command shortcuts to work efficiently in Vim.

Move efficiently within a file using these commands.

Move to line start

Jumps to the first character of the current line.

0

Move to line end

Jumps to the last character of the current line.

SHIFT+4

Move to 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.

%

Add indent

Increases the indentation level.

CTRL+t

Remove indent

Decreases the indentation level.

CTRL+d

Selecting Text

Commands for selecting, deselecting, and highlighting text.

Select characters

Starts visual mode to select text character by character.

v
Use arrow keys to expand selection.

Select lines

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

Clear selection

Exits visual mode and clears selection.

ESC

Editing

Modify text with essential Vim commands.

Enter insert mode

Enters insert mode to start typing.

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

Exit insert mode

Escapes the insert mode.

ESC

Replace character

Replaces the character under the cursor.

r+[new character]

Change word

Deletes the word under the cursor and enters insert mode.

caw

Delete character

Deletes the character under the cursor.

x

Delete word

Deletes the word under the cursor.

daw

Copy text

Copies the selected text or the current line.

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

Cut text

Cuts the selected text or the current line.

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

Paste text

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 selection or current line to system clipboard.

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

Cut to system clipboard

Cuts selection or current line to 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 change

Reverts the last edit.

u

Redo change

Reapplies the last undone change.

CTRL+r

Search and Replace

Find text and perform replacements efficiently.

Search forward

Finds the next occurrence of a word in the file.

/word+ENTER

Search backward

Finds the previous occurrence of a word in the file.

?word+ENTER

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 on 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 new tab

Opens a new tab in Vim.

:tabnew+ENTER

Switch tabs

Moves to the next or previous tab.

gt
or
gT
gt=next, gT=previous

Split horizontal

Splits the window into two horizontal panes.

CTRL+w+s

Split vertical

Splits the window into two vertical panes.

CTRL+w+v

Switch windows

Moves the cursor between split windows.

CTRL+w+[arrow key]

Miscellaneous

Other useful Vim configuration 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