Vim Cheatsheet
Basic Vim motions to get you started.
Movement
h j k l- Left, Down, Up, Right (recommended over the arrow keys)w b- Go forward a word, go back a word{ }- Jump up and down whole code blocksgg- Go to the top of the documentG- Go to the bottom of the document0- Go to the beginning of the line^- Go to the first non-whitespace character of the line$- Go to the end of the line
Editing
yy- Copy a linedd- Delete a line (similar to cut)p- Paste what was yanked or deleted after the cursoru- Undoctrl + r- Redox- Delete a characterr- Replace a characterdorycombined with any other movement options to delete or yank different selections likedwto delete a word ordjto delete the line and the line below it.shift + d- Delete from the cursor to the end of the lineshift + y- Copy from the cursor to the end of the lineshift + p- Paste before the cursorgg=G- Format your document
Visual Mode
Used for highlighting and selecting text.
v- visual mode for text selectionshift + v- visual line mode, for selecting whole linesy d- in visual mode to copy or cut selectionp- Paste over selection
Insert Mode
i- Insert mode before the cursora- Insert mode after the cursorshift + i- Insert mode at the beginning of the lineshift + a- Insert mode at the end of the lineo- Insert mode on a new line below the cursorshift + o- Insert mode on a new line above the cursorc- Same asdbut also enters insert modecc- Delete a line and enter insert modeshift + c- Delete from the cursor to the end of the line and enter insert modeescape- exit insert mode
Exiting
:q- Close a document:wq- Save and exit a document:q!- Close the document without savingshift + zz- An alias for:wqto save and exit a documentshift + zq- An alias for:q!to save and exit a document
Neovim keymaps
Useful actions specific to Neovim kickstart.
ctrl + y- Accept autocomplete suggestionspace f- Autoformat withclang-foramt, much more thorough formatter thangg=Gspace rn- Rename the variable under the cursorgcc- Comment toggle a linespace ds- Search document symbols: functions, class names, etcspace /- Search the current fileshift + K- Show LSP information for the symbol under the cursor
If you want to dive deeper into Vim, this YouTuber, The Primeagen is a good place to start.