Normal Mode:
h,j,k,l: Move the cursor left, down, up, and right respectively.w: Move forward to the beginning of the next word.b: Move backward to the beginning of the previous word.0(zero): Move to the beginning of the line.$: Move to the end of the line.gg: Go to the first line of the document.G: Go to the last line of the document.u: Undo the last action.Ctrl-r: Redo the last undone action.x: Delete the character under the cursor.dd: Delete the current line.yy: Yank (copy) the current line.p: Paste the yanked or deleted text after the cursor.P: Paste the yanked or deleted text before the cursor./:Enter search mode to find a specific string.n: Find the next occurrence of the searched string.N: Find the previous occurrence of the searched string.v: Enter Visual mode.
Insert Mode:
i: Enter Insert mode to insert text.a: Enter Insert mode to append text.o: Create a new line below the current line and enter Insert mode.O: Create a new line above the current line and enter Insert mode.Esc: Exit Insert mode and return to Normal mode.
Command-Line Mode:
:w: Save the file.:q: Quit Vim (will not work if there are unsaved changes).:wqor:x: Save and quit.:q!: Quit without saving.:e filename: Edit a different file.:%s/old/new/g: Replace all occurrences of ‘old’ with ‘new’.:set number: Show line numbers.:set nonumber: Hide line numbers.
Visual Mode:
v: Start Visual mode for character selection.V: Start Visual mode for line selection.Ctrl-v: Start Visual mode for block selection.y: Yank (copy) selected text.d: Delete selected text.
This is just a small subset of Vim’s vast command set. Vim is highly customizable and has a strong scripting capability, so there are many more commands and options to explore. For a more comprehensive list and explanation, consider checking the Vim documentation or running :help within Vim.