VIM Cheatsheet

Command Description
, Repeats the previous f, t, F, or T cursor movement command in the opposite direction.
; Repeats the previous f, t, F, or T cursor movement command in the same direction.
:%s/old/new/g Replaces all occurrences of 'old' with 'new' throughout the entire file.
:%s/old/new/gc Replaces all occurrences of 'old' with 'new' throughout the entire file, prompting for confirmation before each replacement.
:3,5d Deletes lines 3 through 5.
:b[uffer] file Switches to the buffer associated with the specified file name.
:b[uffer]# Switches to the buffer identified by its index number.
:bd[elete] Deletes a specified buffer, which effectively closes the associated file.
:bn[ext] Switches to the next buffer.
:bp[revious] Switches to the previous buffer.
:ccl[ose] Closes the quickfix window, which contains the list of search results.
:changes Displays a list of all recent changes made in the buffer.
:clo[se] Closes the current pane in Vim.
:cn[ext] Jumps to the next match from a previous search.
:cope[n] Opens a window that displays a list of matches from the previous search.
:cp[revious] Jumps to the previous match from a previous search.
:dif[fupdate] Updates the displayed differences between buffers in diff mode.
:diffo[ff] Disables diff mode for the current window.
:diffthis Marks the current window as part of the diff comparison.
:e[dit] file Opens a specified file for editing in a new buffer.
:h[elp] keyword Opens the help page for the specified keyword in Vim.
:ju[mps] Displays a list of all recent jumps.
:ls or :buffers Displays a list of all currently open buffers.
:marks Displays a list of all saved marks.
:noh[lsearch] Removes the highlighting of search matches.
:q Exits Vim. Fails if there are unsaved changes.
:q! or ZQ Exits Vim and discards any unsaved changes.
:reg[isters] Displays the contents of all registers.
:sav[eas] file Saves the current file with the specified file name.
:sp[lit] file Opens a specified file in a new buffer and splits the window horizontally to display it.
:tab ba[ll] Opens all open buffers in separate tabs.
:tabc[lose] Closes the current tab and all its associated windows.
:tabdo command Runs the specified command on all open tabs.
:tabm[ove] # Moves the current tab to the position specified by the number # (indexed from 0).
:tabnew or :tabnew {page.words.file} Opens a new tab, optionally with a specified file.
:tabo[nly] Closes all tabs except the currently active tab.
:ter[minal] Opens a terminal window within Vim.
:vert[ical] ba[ll] Arranges all open buffers as vertical windows.
:vim[grep] /pattern/ {`{file}`} Searches for a given pattern in multiple files.
:vs[plit] file Opens a specified file in a new buffer and splits the window vertically to display it.
:w Saves the current file without exiting Vim.
:w !sudo tee % Saves the current file using sudo (superuser privileges). This is useful when you don't have write permissions to the file.
:wq or :x or ZZ Saves the current file and exits Vim.
:wqa Saves all open files and exits Vim.
?pattern Searches backward for the specified pattern.
. Repeats the last executed command.
'" Moves the cursor to the position when you last edited this file.
"+p Pastes the contents of the system clipboard.
"+y Copies (yanks) the selected text into the system clipboard.
"xp Pastes the contents of the specified register x.
"xy Copies (yanks) the selected text into the specified register x.
[c Jumps to the start of the previous change in the document.
]c Jumps to the start of the next change in the document.
]p Pastes the contents of the default register (") and adjusts the indentation to match the current line.
{ Moves the cursor to the beginning of the previous paragraph. When editing code, it moves to the previous function or block.
} Moves the cursor to the beginning of the next paragraph. When editing code, it moves to the next function or block.
@@ Repeats the last executed macro.
@a Executes the macro stored in register 'a'.
/pattern Searches forward for the specified pattern.
\vpattern Searches for the specified pattern using 'very magic' mode, where non-alphanumeric characters are interpreted as special regex symbols without escaping.
#gt Moves to the tab specified by the number #.
% Moves the cursor to the matching character of a pair, such as parentheses, brackets, or braces. Use :h matchpairs in Vim for more information on supported pairs.
`.` Moves the cursor to the position of the last change in this file.
`` Moves the cursor to the position before the last jump.
`0 Moves the cursor to the position where Vim was last exited.
`a Moves the cursor to the position marked as A.
^ Moves the cursor to the first non-blank character on the current line.
< In visual mode, shifts the selected text one indentation level to the left.
<% De-indents a block enclosed by parentheses () or curly brackets {}, with the cursor positioned on the opening or closing brace.
<< De-indents the current line one shiftwidth to the left.
=% Re-indents a block enclosed by parentheses () or curly brackets {}, with the cursor positioned on the opening or closing brace.
=iB Re-indents the inner block enclosed by curly brackets {}.
> In visual mode, shifts the selected text one indentation level to the right.
>% Indents a block enclosed by parentheses () or curly brackets {}, with the cursor positioned on the opening or closing brace.
>> Indents the current line one shiftwidth to the right.
>at Indents a block enclosed by angle brackets <> (tags).
>ib Indents the inner block enclosed by parentheses ().
~ In visual mode, switches the case (uppercase/lowercase) of the selected text.
$ Moves the cursor to the end of the current line.
0 Moves the cursor to the very beginning of the current line.
2dd Deletes the current line and the next line and places them in the default register (").
2yy Copies the current line and the next line into the default register (").
3== Re-indents the current line and the two lines below it.
5gg or 5G Moves the cursor to line number 5 in the document.
a Enters insert mode and starts inserting text after the cursor position.
A Enters insert mode and starts inserting text at the end of the current line.
ab In visual mode, selects a block of text enclosed by parentheses ().
aB In visual mode, selects a block of text enclosed by curly braces {}.
at In visual mode, selects a block of text enclosed by angle brackets <> (often used for tags).
aw In visual mode, selects the current word.
b Moves the cursor backward to the beginning of the previous word.
B Moves the cursor backward to the beginning of the previous word, considering punctuation as part of the word.
c$ or C Replaces text from the cursor position to the end of the current line.
cc Replaces the content of the entire current line.
ciw Replaces the entire word under the cursor.
Ctrl + ] Jumps to the definition of the tag under the cursor.
Ctrl + b Scrolls the screen up one page and moves the cursor to the last line of the new page.
Ctrl + d Scrolls the screen down half a page and moves the cursor accordingly.
Ctrl + d De-indents the current line one shiftwidth to the left while in insert mode.
Ctrl + e Scrolls the screen down one line without moving the cursor.
Ctrl + f Scrolls the screen down one page and moves the cursor to the first line of the new page.
Ctrl + h Deletes the character before the cursor while in insert mode.
Ctrl + i Moves the cursor to the next newer position in the jump list.
Ctrl + j Inserts a line break at the current cursor position while in insert mode.
Ctrl + n Inserts the next matching completion before the cursor while in insert mode.
Ctrl + o Moves the cursor to the next older position in the jump list.
Ctrl + ox Temporarily switches to normal mode from insert mode to execute a single normal mode command 'x'. After executing the command, it returns to insert mode.
Ctrl + p Inserts the previous matching completion before the cursor while in insert mode.
Ctrl + r Redoes a previously undone change.
Ctrl + rx Inserts the contents of register 'x' at the cursor position.
Ctrl + t Indents the current line one shiftwidth to the right while in insert mode.
Ctrl + u Scrolls the screen up half a page and moves the cursor accordingly.
Ctrl + v Starts visual block mode, allowing you to select a rectangular block of text.
Ctrl + w Deletes the word before the cursor while in insert mode.
Ctrl + w= Resizes all windows in the current split arrangement to have equal height and width.
Ctrl + wh Moves the cursor to the window located to the left in a vertical split arrangement.
Ctrl + wH Makes the current window occupy the full height of the screen and positions it as the leftmost window in a vertical split arrangement.
Ctrl + wj Moves the cursor to the window located below in a horizontal split arrangement.
Ctrl + wJ Makes the current window occupy the full width of the screen and positions it as the bottommost window in a horizontal split arrangement.
Ctrl + wk Moves the cursor to the window located above in a horizontal split arrangement.
Ctrl + wK Makes the current window occupy the full width of the screen and positions it as the topmost window in a horizontal split arrangement.
Ctrl + wl Moves the cursor to the window located to the right in a vertical split arrangement.
Ctrl + wL Makes the current window occupy the full height of the screen and positions it as the rightmost window in a vertical split arrangement.
Ctrl + wq Closes the currently active window within a split arrangement.
Ctrl + ws Splits the current window horizontally, creating a new split.
Ctrl + wT Moves the currently active split window into its own new tab.
Ctrl + wv Splits the current window vertically, creating a new split.
Ctrl + ww Switches the focus to the next window within the current split arrangement.
Ctrl + wx Exchanges the position of the current window with the next one in the split arrangement.
Ctrl + y Scrolls the screen up one line without moving the cursor.
cw or ce Replaces text from the cursor position to the end of the current word.
d In visual mode, deletes the selected text.
d$ or D Deletes the characters from the cursor position to the end of the line and places them in the default register (").
daw Deletes the word under the cursor and the space after or before it and places it in the default register (").
dd Deletes the current line and places it in the default register (").
diw Deletes the word under the cursor and places it in the default register (").
do or :diffg[et] Obtains (gets) the difference from another buffer and applies it to the current buffer.
dp or :diffpu[t] Puts (applies) the difference from the current buffer to another buffer.
dw Deletes the characters of the word from the cursor position to the start of the next word and places them in the default register (").
e Moves the cursor forward to the end of the current word.
E Moves the cursor forward to the end of the current word, considering punctuation as part of the word.
ea Moves the cursor to the end of the current word and enters insert mode.
Esc or Ctrl + c Exits insert mode and returns to normal mode.
Esc or Ctrl + c Exits visual mode.
fx Moves the cursor to the next occurrence of character 'x' on the current line.
Fx Moves the cursor to the previous occurrence of character 'x' on the current line.
G Moves the cursor to the last line of the document.
g_ Moves the cursor to the last non-blank character on the current line.
g, Moves the cursor to the next newer position in the change list.
g; Moves the cursor to the next older position in the change list.
g~ Switches the case of characters (uppercase to lowercase or vice versa) from the cursor position to the end of the specified motion.
gd Moves the cursor to the local declaration of the variable under the cursor (useful for code editing).
gD Moves the cursor to the global declaration of the variable under the cursor (useful for code editing).
ge Moves the cursor backward to the end of the previous word.
gE Moves the cursor backward to the end of the previous word, considering punctuation as part of the word.
gg Moves the cursor to the first line of the document.
gg=G Re-indents the entire buffer (all lines in the current file).
gj Moves the cursor down one line, considering wrapped lines as a single line.
gJ Joins the line below the current line to the end of the current line without adding any space.
gk Moves the cursor up one line, considering wrapped lines as a single line.
gp Pastes the contents of the default register (") after the cursor and leaves the cursor after the new text.
gP Pastes the contents of the default register (") before the cursor and leaves the cursor after the new text.
gt or :tabn[ext] Navigates to the next tab.
gT or :tabp[revious] Navigates to the previous tab.
gu Changes the characters from the cursor position to the end of the specified motion to lowercase.
gU Changes text to uppercase up to the specified motion.
gwip Reflows the current paragraph, adjusting line breaks to fit within the current window width.
h Moves the cursor one character to the left.
H Moves the cursor to the top of the screen.
i Enters insert mode and starts inserting text before the cursor position.
I Enters insert mode and starts inserting text at the beginning of the current line.
ib In visual mode, selects the text within the nearest enclosing parentheses ().
iB In visual mode, selects the text within the nearest enclosing curly braces {}.
it In visual mode, selects the text within the nearest enclosing angle brackets <> (often used for tags).
j Moves the cursor one line down.
J Joins the line below the current line to the end of the current line, adding a single space in between.
k Moves the cursor one line up.
K Opens the man page for the word currently under the cursor.
l Moves the cursor one character to the right.
L Moves the cursor to the bottom of the screen.
M Moves the cursor to the middle of the screen.
ma Sets the current cursor position as mark A. You can use any letter for the mark name.
n Repeats the last search in the same direction (forward).
N Repeats the last search in the opposite direction (backward).
o Opens a new line below the current line and enters insert mode.
o While in visual mode, this command moves the cursor to the opposite end of the currently selected area.
O Opens a new line above the current line and enters insert mode.
O While in visual block mode, this command moves the cursor to the opposite corner of the selected block.
p Pastes the contents of the default register (") after the cursor.
P Pastes the contents of the default register (") before the cursor.
q Stops recording the current macro.
qa Starts recording a macro and saves it in register 'a'.
r Replaces the character under the cursor with the next character typed.
R Enters replace mode, allowing you to replace multiple characters until the ESC key is pressed.
s Deletes the character under the cursor and enters insert mode to allow substitution of text (same as cl).
S Deletes the entire line and enters insert mode to allow substitution of text (same as cc).
tx Moves the cursor to the position before the next occurrence of character 'x' on the current line.
Tx Moves the cursor to the position after the previous occurrence of character 'x' on the current line.
u Reverses the last editing action.
u In visual mode, changes the selected text to lowercase.
U Restores the last changed line to its state before any modifications were made.
U In visual mode, changes the selected text to uppercase.
v Starts visual mode, allowing you to select text by moving the cursor. Once text is selected, you can perform various commands on it (like yanking/copying).
V Starts linewise visual mode, which allows you to select entire lines by moving the cursor.
w Moves the cursor forward to the beginning of the next word.
W Moves the cursor forward to the beginning of the next word, considering punctuation as part of the word.
x Deletes the character under the cursor and places it in the default register (").
xp Transposes the character under the cursor with the character to its right (effectively deleting and pasting).
y In visual mode, copies (yanks) the selected text into the clipboard.
y`a Copies (yanks) the selected text and places it at the position marked as A.
y$ or Y Copies the characters from the cursor position to the end of the line into the default register (").
yaw Copies the word under the cursor and the space after or before it into the default register (").
yiw Copies the word under the cursor into the default register (").
yw Copies the characters of the word from the cursor position to the start of the next word into the default register (").
yy Copies the current line into the default register (").
za Toggles the open/closed state of the code fold located under the cursor.
zb Positions the cursor at the bottom of the screen.
zc Closes (collapses) the code fold located under the cursor.
zd Deletes the code fold located under the cursor.
zf Manually defines a code fold from the current cursor position up to the specified motion.
zi Toggles the folding functionality on or off.
zm Increases the folding level by one, effectively closing folds at the current level.
zo Opens (expands) the code fold located under the cursor.
zr Reduces the folding level by one, effectively opening folds at the outermost level.
zt Positions the cursor at the top of the screen.
zz Centers the cursor vertically on the screen.
Gemacht mit ❤️ und Astro
© 2025
Impressum
Datenschutz