Vim Keyboard Shortcuts — Complete Cheatsheet
Vim is a highly efficient and customizable text editor, and mastering its keyboard shortcuts is fundamental to unlocking its full power and significantly boosting your coding and text editing speed.
Upgrade Your Workflow: MX Master 3S Mouse
Pair your shortcuts with the ultimate developer mouse. Silent clicks, 8K DPI tracking, and hyper-fast scrolling.
Shortcuts
| Action | Windows | Mac | Category |
|---|---|---|---|
| Save current file | :w | :w | File Operations |
| Save and Quit | :wq | :wq | File Operations |
| Quit without saving | :q! | :q! | File Operations |
| Open a file | :e <filename> | :e <filename> | File Operations |
| Undo last change | u | u | Editing |
| Redo last change | Ctrl+r | Cmd+r | Editing |
| Copy (yank) line | yy | yy | Editing |
| Paste after cursor | p | p | Editing |
| Delete line | dd | dd | Editing |
| Delete character under cursor | x | x | Editing |
| Insert mode (before cursor) | i | i | Modes |
| Insert mode (at end of line) | A | A | Modes |
| Insert mode (new line below) | o | o | Modes |
| Normal mode (from any other mode) | Esc | Esc | Modes |
| Move cursor left | h | h | Navigation |
| Move cursor down | j | j | Navigation |
| Move cursor up | k | k | Navigation |
| Move cursor right | l | l | Navigation |
| Go to beginning of line | 0 | 0 | Navigation |
| Go to end of line | $ | $ | Navigation |
| Go to next word | w | w | Navigation |
| Go to previous word | b | b | Navigation |
| Search forward | /<pattern> | /<pattern> | Search & Replace |
| Search backward | ?<pattern> | ?<pattern> | Search & Replace |
| Repeat last search | n | n | Search & Replace |
| Replace all occurrences in file | :%s/<old>/<new>/g | :%s/<old>/<new>/g | Search & Replace |
Tips
- Practice regularly: Muscle memory is key. The more you use Vim's shortcuts, the more natural they become.
- Learn in chunks: Don't try to memorize everything at once. Focus on a few new shortcuts each day and integrate them into your workflow.
- Use Vimtutor: Vim comes with an excellent interactive tutorial. Run `vimtutor` in your terminal to get hands-on practice.
- Combine commands: Vim's power comes from combining commands (e.g., `dw` to delete a word, `3dd` to delete 3 lines).
- Customize your .vimrc: As you become more proficient, tailor Vim to your needs by adding custom mappings and settings to your `.vimrc` file.
Frequently Asked Questions
How do I see all Vim shortcuts?
Vim doesn't have a single 'show all shortcuts' command in the way graphical editors do. You can use `:help index` to browse the help system, or `:help <command>` for specific commands. Many users rely on external cheat sheets or their `~/.vimrc` file for custom mappings.
Can I customise Vim shortcuts?
Absolutely! Vim is highly customizable. You can define your own key mappings using the `map`, `nmap`, `vmap`, `imap`, etc., commands in your `~/.vimrc` file. For example, `nmap <leader>s :w<CR>` would map your leader key followed by 's' to save the file.