| Category | Command | Description |
|---|---|---|
| File Operations | :e filename | Open a file by name. |
| :w | Save the current file. | |
| :q | Quit Gvim. | |
| :wq | Save and quit. | |
| :x | Save and quit (similar to :wq). | |
| :q! | Quit without saving changes. | |
| :sav filename | Save the file with a new name. | |
| Editing | i | Enter insert mode. |
| a | Enter insert mode after the cursor. | |
| o | Open a new line below the current one and enter insert mode. | |
| O | Open a new line above the current one and enter insert mode. | |
| x | Delete the character under the cursor. | |
| dw | Delete a word. | |
| dd | Delete the entire current line. | |
| u | Undo the last change. | |
| Ctrl + r | Redo the last undone change. | |
| y | Yank (copy) selected text. | |
| p | Paste the yanked text after the cursor. | |
| P | Paste the yanked text before the cursor. | |
| :s/old/new/gc | Search and replace old with new globally, with confirmation. | |
| Navigation | h, j, k, l | Move cursor left, down, up, right. |
| gg | Go to the first line of the file. | |
| G | Go to the last line of the file. | |
| :n | Go to line number n. | |
| w | Move forward to the next word. | |
| b | Move backward to the previous word. | |
| % | Jump to the matching bracket, brace, or parenthesis. | |
| Ctrl + o | Jump back to the previous cursor position. | |
| Visual Mode | v | Enter visual mode to select characters. |
| V | Enter visual line mode to select entire lines. | |
| Ctrl + v | Enter visual block mode to select a block of text. | |
| d (in visual mode) | Delete the selected text. | |
| y (in visual mode) | Yank (copy) the selected text. | |
| > (in visual mode) | Indent the selected lines. | |
| < (in visual mode) | Unindent the selected lines. | |
| Window Operations | :split filename | Split the window and open a file. |
| :vsplit filename | Vertically split the window and open a file. | |
| Ctrl + w, w | Switch between windows. | |
| Ctrl + w, q | Quit the current window. | |
| Ctrl + w, h/j/k/l | Move cursor to another window in the specified direction. | |
| Miscellaneous | :syntax on | Enable syntax highlighting. |
| :set number | Show line numbers. | |
| :set nowrap | Disable line wrapping. | |
| :set paste | Disable auto-indentation and other formatting when pasting. |
Tags:
linux