# Neovim command and keybind cheat sheet Some of these are plain Vim commands, others are specific to Neovim. ## BASICS - `Space` leader key - `:checkhealth []` check base or status - `:verbose set expandtab?` check where `expandtab` has been set last - `:Lazy` show package manager UI - `:Lazy restore` revert plugins to the state reflected in `lazy-lock.json` - `:Mason` show Mason UI - `:TSUpdate` update all treesitter parsers - `:TSModuleInfo` show installed treesitter parsers - `:LspInfo` show currently attached LSP client details - `:ConformInfo` useful to debug why a formatter times out ## NAVIGATING ## Tabs - `Ctrl`+`t` open a file in e.g. a Telescope finder in a new tab - `gt` or `gT` switch between open tabs (forward/reverse direction) ## Windows/splits - `Ctrl`+`wq` close window - `Ctrl`+`ws` split window **horizontally** - `Ctrl`+`wv` split window **vertically** - `Ctrl`+`` move between split windows - `Ctrl`+`w=` equalize split window width and height - `Ctrl`+`wr` swap position of two windows - `Ctrl`+`wT` move active split window to new tab ## Buffers - `Space`+`Space` shows buffers sorted by last used (via `Telescope buffers`) - `:bd` close current buffer - `:bn` go to next buffer - `:bp` go to previous buffer ## Code - `w` move to **start of next word** (ignores punctuation due to remap) - `e` move to **end of next word** (ignores punctuation due to remap) - `b` move to **start of previous word** (ignores punctuation due to remap) - `Ctrl`+`0` start of line - `Ctrl`+`$` end of line - `Ctrl`+`d` scroll **down** 1/2 page while keeping the cursor centered - `Ctrl`+`u` scroll **up** 1/2 page while keeping the cursor centered - `Ctrl`+`o` jump to location you were before (e.g. after using `gg`) - `Ctrl`+`i` jump back to location you were before (after using `Ctrl`+`o`) - `f` jump forward to `` - `F` jump backwards to `` - `t` jump forward just before `` - `T` jump backwards just before `` - `;` jump to next occurence of (same line only) - `,` jump to previous occurence of (same line only) ## LSP - `Ctrl`+`n/p` scroll down/up through LSP suggestions - `Ctrl`+`l` accept selected suggestion - `gd` go to definition ## Diagnostics - `gd` go to definition - `leader`+`qq` toggle trouble.nvim quickfix list - `leader`+`da` go to next diagnostic (any severity) - `leader`+`dw` go to next diagnostic (warning severity) - `leader`+`de` go to next diagnostic (error severity) ## Telescope windows - `↓` or `Ctrl`+`n` scroll down (**n**ext) file list - `↑` or `Ctrl`+`p` scroll up (**p**revious) file list - `Ctrl`+`d` scroll **d**own in preview pane - `Ctrl`+`u` scroll **u**p in preview pane - `Ctrl`+`/` help - `Ctrl`+`v` open file in **vertical** split - `Ctrl`+`x` open file in **horizontal** split - `Ctrl`+`t` open file in new tab - `Ctrl`+`q` send all items to quickfix list - `Alt`+`q` send selected items to quickfix list ## EDITING ### Code editing - `leader`+`i` re-indent whole file - `leader`+`o` re-format whole file or visual with `conform.nvim` - `i` insert mode at cursor position - `I` insert mode at the **beginning of the line** - `a` insert mode **one character after the current** one - `A` insert mode at the **end of the line** - `o` insert mode a line **below** the cursor - `O` insert mode a line **above** the cursor - `s` delete character and replace (substitute) it - `cw` replace the current word - `cc` replace whole line - `C` replace to the end of the line - `yy` copy (yank) the current line - `p` paste yanked line below - `P` paste yanked line above - `"3p` redo (put) e.g. your third last delete [source](https://www.reddit.com/r/neovim/comments/18ri1bm/its_been_like_10_years_and_i_just_learned_that/) ### Visual mode - `v` at cursor position - `V` line mode - `Ctrl`+`v` block mode ## SEARCH/OPEN - `leader`+`fg` search text in files (also searches for text under cursor) - `leader`+`ff` search files (respects `.gitignore`) - `leader`+`e` toggles Oil file explorer - `leader`+`fo` recently opened files - `gf` open file under cursor in a new buffer - `gx` open link under cursor in default browser - `*` search marked word