neovim/CHEATSHEET.md

129 lines
4.1 KiB
Markdown
Raw Normal View History

2024-01-18 15:13:29 +01:00
# Neovim command and keybind cheat sheet
2024-01-19 08:14:11 +01:00
## BASICS
2024-01-18 15:13:29 +01:00
- `Space` leader key
2024-02-03 22:14:07 +01:00
- `:checkhealth [<pluginname>]` check base or <pluginname> status
2024-01-19 08:14:11 +01:00
- `:verbose set expandtab?` check where `expandtab` has been set last
2024-01-18 15:13:29 +01:00
- `:Lazy` show package manager UI
- `:Lazy restore` revert plugins to the state reflected in `lazy-lock.json`
2024-01-18 15:13:29 +01:00
- `:Mason` show Mason UI
2024-02-03 22:14:07 +01:00
- `:TSUpdate` update all treesitter parsers
- `:TSModuleInfo` show installed treesitter parsers
2024-01-19 08:14:11 +01:00
- `:LspInfo` show currently attached LSP client details
2024-01-22 22:23:59 +01:00
- `:ConformInfo` useful to debug why a formatter times out
2024-01-19 08:14:11 +01:00
2024-02-03 22:14:07 +01:00
## NAVIGATING
2024-01-18 15:13:29 +01:00
## Tabs
2024-03-05 09:32:10 +01:00
- `gt` or `gT` switch forward/reverse between tabs
2024-01-18 15:13:29 +01:00
2024-02-03 22:14:07 +01:00
## Windows/splits
2024-01-18 15:13:29 +01:00
- `Ctrl`+`wq` close window
- `Ctrl`+`ws` split window **horizontally**
- `Ctrl`+`wv` split window **vertically**
- `Ctrl`+`<h/j/k/l>` move between split windows
- `Ctrl`+`w=` equalize split window width and height
- `Ctrl`+`wr` swap position of two windows
2024-01-19 08:14:11 +01:00
- `Ctrl`+`wT` move active split window to new tab
2024-01-18 15:13:29 +01:00
2024-02-03 22:14:07 +01:00
## Buffers
2024-01-18 15:13:29 +01:00
2024-01-19 08:14:11 +01:00
- `Space`+`Space` shows buffers sorted by last used (via `Telescope buffers`)
2024-01-18 15:13:29 +01:00
- `:bd` close current buffer
2024-01-19 08:14:11 +01:00
- `:bn` go to next buffer
- `:bp` go to previous buffer
2024-01-18 15:13:29 +01:00
2024-03-05 09:32:10 +01:00
## Text
2024-01-18 15:13:29 +01:00
- `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)
2024-02-03 22:14:07 +01:00
- `Ctrl`+`0` start of line
- `Ctrl`+`$` end of line
2024-03-05 09:32:10 +01:00
- `Ctrl`+`d` scroll down 1/2 page while keeping the cursor centered
- `Ctrl`+`u` scroll up 1/2 page while keeping the cursor centered
2024-01-24 11:18:01 +01:00
- `Ctrl`+`o` jump to location you were before (e.g. after using `gg`)
2024-02-03 22:14:07 +01:00
- `Ctrl`+`i` jump back to location you were before (after using `Ctrl`+`o`)
- `f<char>` jump forward to `<char>`
- `F<char>` jump backwards to `<char>`
2024-03-05 09:32:10 +01:00
- `;` jump to next occurence of <char> on same line
- `,` jump to previous occurence of <char> onx same line
2024-02-03 22:14:07 +01:00
2024-03-05 09:32:10 +01:00
## LSP, Code & Diagnostics
2024-02-03 22:14:07 +01:00
- `Ctrl`+`n/p` scroll down/up through LSP suggestions
- `Ctrl`+`l` accept selected suggestion
- `gd` go to definition
2024-03-05 09:32:10 +01:00
- `gr` show references of function
- `leader`+`qq` toggle `trouble.nvim` quickfix list
2024-02-03 22:14:07 +01:00
- `leader`+`da` go to next diagnostic (any severity)
- `leader`+`dw` go to next diagnostic (warning severity)
- `leader`+`de` go to next diagnostic (error severity)
2024-01-18 15:13:29 +01:00
2024-03-05 09:32:10 +01:00
## Telescope
2024-01-19 08:14:11 +01:00
- `↓` 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
2024-02-03 22:14:07 +01:00
- `Ctrl`+`q` send all items to quickfix list
- `Alt`+`q` send selected items to quickfix list
2024-01-19 08:14:11 +01:00
2024-03-05 09:32:10 +01:00
## Oil
- `Ctrl`+`d` bottom of file list
- `Ctrl`+`u` top of file list
- `Ctrl`+`p` preview file
- `Ctrl`+`v` open file in **vertical** split
- `Ctrl`+`x` open file in **horizontal** split
- `Ctrl`+`t` open file in new tab
2024-01-19 08:14:11 +01:00
## EDITING
2024-01-18 15:13:29 +01:00
### Code editing
2024-03-05 09:32:10 +01:00
- `leader`+`o` re-format whole file or visual w/ `conform.nvim`
2024-01-18 15:13:29 +01:00
- `i` insert mode at cursor position
2024-03-05 09:32:10 +01:00
- `I` insert mode at **beginning of line**
- `a` insert mode **after the current char**
- `A` insert mode at **end of line**
2024-01-18 15:13:29 +01:00
- `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
2024-01-19 08:14:11 +01:00
- `cc` replace whole line
- `C` replace to the end of the line
2024-03-05 09:32:10 +01:00
- `yy` copy the current line
- `yap` "yank-around-paragraph"
2024-01-18 15:13:29 +01:00
- `p` paste yanked line below
- `P` paste yanked line above
2024-03-05 09:32:10 +01:00
## SELECTING
2024-01-18 15:13:29 +01:00
### Visual mode
- `v` at cursor position
- `V` line mode
- `Ctrl`+`v` block mode
2024-03-05 09:32:10 +01:00
### Code selection
- `leader`+`Space` context-sensitive text selection w/ `treesitter`
- `Backspace` reduce context-sensitive selection
2024-02-03 22:14:07 +01:00
## SEARCH/OPEN
2024-01-18 15:13:29 +01:00
- `leader`+`fg` search text in files (also searches for text under cursor)
- `leader`+`ff` search files (respects `.gitignore`)
2024-01-22 22:23:59 +01:00
- `leader`+`e` toggles Oil file explorer
2024-01-18 15:13:29 +01:00
- `leader`+`fo` recently opened files
2024-02-03 22:14:07 +01:00
- `gf` open file under cursor in a new buffer
- `gx` open link under cursor in default browser
- `*` search marked word