| Switch to edit mode (before cursor) |
i |
Switches from normal mode to insert mode, letting you type text immediately before the character under the cursor. It is one of the most frequently used commands for entering new text in Vim. |
| Switch to normal mode |
Esc |
Returns to Vim's default normal mode from other modes such as insert or visual mode. Since navigation, copying, and deleting are performed in normal mode, this is a key you use after every round of editing. |
| Switch to edit mode (behind the cursor) |
a |
Switches from normal mode to insert mode, letting you type text immediately after the character under the cursor. Unlike i, insertion starts one position later, which is handy for appending text at the end of a line. |
| Return to normal mode (ctrl press var) |
Ctrl+[ |
Works the same as the Escape key, returning to normal mode from insert mode and similar modes. It is often used instead of Escape when you want to switch modes without moving your hands from the home row. |
| Insert line below to enter mode |
o |
Inserts a new blank line below the current line and enters insert mode on it. It is handy for starting a new line of code or text regardless of where the cursor was on the current line. |
| Insert a line above and enter input mode |
Shift+O |
Inserts a new blank line above the current line and enters insert mode on it. It works in the opposite direction to o, used when you want to add a new line before the current one. |
| Go to the beginning of the line and enter input mode |
Shift+I |
Moves the cursor to the first non-blank character of the line and enters insert mode there. It combines ^ and i in one step, handy for adding text at the beginning of a line. |
| Go to end of line and enter input mode |
Shift+A |
Moves the cursor to the end of the current line and enters insert mode there. It combines $ and a in one step, and is very commonly used to append text at the end of a line. |
| Replace the character on the cursor with "M" |
r Shift+M |
In normal mode, typing "r" followed by a character replaces just the single character under the cursor with it. This example replaces it with "M"; the key benefit is fixing one character on the spot without entering insert mode. |
| Enter "vim" in multi-character replacement mode |
Shift+R v i m |
Pressing R (uppercase) enters replace mode, where typed characters overwrite the existing text from the cursor position onward. Here "vim" is typed; it is used when you want to correct text by directly overtyping it. |
| Switch to normal mode |
Esc |
Returns to normal mode from insert mode, replace mode, and similar modes. After typing or replacing text, this key brings you back to the standard operating mode. |
| Erase one character |
x |
Deletes the single character under the cursor in normal mode. It is the quickest way to remove just one mistyped character on the spot. |
| Change to visual mode |
v |
Switches from normal mode to visual mode (character-wise selection). Moving the cursor extends the selection, which can then be acted on with commands like y (yank) or d (delete). |
| Move to end of word |
e |
Moves the cursor to the end of a word, whether in normal mode or visual mode. Used while in visual mode, it extends the selection to the end of the word. |
| Yank (copy) |
y |
Yanks (copies) the range selected in visual mode into a register. It corresponds to "copy" in copy-and-paste, used when you want to duplicate the selected text elsewhere. |
| Paste what you yank |
p |
Pastes the most recently yanked (copied) or deleted content after the cursor position. It corresponds to "paste" in copy-and-paste, and is an operation used constantly when editing in Vim. |
| Erase one line |
d d |
Deletes the entire current line in normal mode. It is used to remove an unwanted line in one go, and the deleted content is automatically stored in a register. |
| Yank (copy) one line |
y y |
Yanks (copies) the entire current line in normal mode. When you want to copy a whole line, this single command does it without needing to select a range first. |
| Paste what you yank |
p |
Pastes the line just yanked with yy below the line where the cursor is. It is used to duplicate a copied line or move it to another location. |
| Delete the contents of the html tag and enter edit mode |
cit |
With the cursor inside an HTML tag, this deletes only the content between the opening and closing tags and enters insert mode there. It combines "c" (change) with "it" (inner tag), useful for rewriting just the tag's content while keeping the tag structure intact. |
| Select contents of html tag |
vit |
With the cursor inside an HTML tag, this selects, in visual mode, just the content between the tags. It combines "v" (visual) with "it" (inner tag), typically used before yanking or deleting the tag's content as a whole. |
| Delete contents of html tag |
dit |
With the cursor inside an HTML tag, this deletes just the content between the tags. It combines "d" (delete) with "it" (inner tag), used when you want to empty the content while keeping the tag itself. |
| Yank the contents of html tag (copy) |
yit |
With the cursor inside an HTML tag, this yanks (copies) just the content between the tags. It combines "y" (yank) with "it" (inner tag), useful for duplicating just the tag's content elsewhere. |
| Delete the contents of "" and enter edit mode |
c i Shift+" |
With the cursor inside a double-quoted string, this deletes only the text between the quotes and enters insert mode there. It combines "c" with "i\"" (inner quote), useful for rewriting just the value of a string. |
| Select the contents of "" |
v i Shift+" |
With the cursor inside a double-quoted string, this selects, in visual mode, just the text between the quotes. It is used as a selection step before copying or checking the value. |
| Erase the contents of "" |
d i Shift+" |
With the cursor inside a double-quoted string, this deletes only the text between the quotes. It is used when you want to empty the value while keeping the quotes themselves. |
| Yank (copy) the contents of "" |
y i Shift+" |
With the cursor inside a double-quoted string, this yanks (copies) only the text between the quotes. It is useful when you want to copy just the value to another location. |
| Erase the word on the cursor and enter edit mode |
ciw |
Deletes only the word under the cursor and enters insert mode there. It combines "c" with "iw" (inner word), commonly used to rewrite a single word on the spot without manually selecting it. |
| Select word on cursor |
viw |
Selects the entire word under the cursor in visual mode. It combines "v" with "iw" (inner word), convenient for selecting a whole word before yanking or deleting it. |
| Erase word on cursor |
diw |
Deletes the entire word under the cursor. It combines "d" with "iw" (inner word), used to remove a whole word at once without the effort of manually selecting part of it. |
| Yank (copy) the word on the cursor |
yiw |
Yanks (copies) the entire word under the cursor. It combines "y" with "iw" (inner word), saving the effort of manually selecting a range when you want to copy a single word. |