neovim/CHEATSHEET.md

124 lines
3.9 KiB
Markdown
Raw Normal View History

2025-04-28 12:49:21 +02:00
# Neovim cheat sheet
2024-01-18 15:13:29 +01:00
2025-05-20 15:53:29 +02:00
Heavily customized. Related blog post: https://lugh.ch/neovim-lessons-learned.html
2024-01-19 08:14:11 +01:00
## BASICS
2024-01-18 15:13:29 +01:00
2024-10-21 14:46:23 +02:00
- `:checkhealth [<pluginname>]` check base or plugin status
- `:checkhealth vim.lsp` show details of LSP attached to buffer
2024-01-19 08:14:11 +01:00
- `:verbose set expandtab?` check where `expandtab` has been set last
2025-05-20 15:53:29 +02:00
- `:Lazy` show package manager TUI
- `:Mason` show LSP management TUI
2024-10-21 14:46:23 +02:00
- `:TSUpdate` update all Tree-sitter parsers
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
2025-01-23 10:38:39 +01:00
## Windows, splits & tabs
2024-01-18 15:13:29 +01:00
- `Ctrl`+`wq` close window
- `Ctrl`+`ws` split window **horizontally**
- `Ctrl`+`wv` split window **vertically**
2024-10-21 14:46:23 +02:00
- `Ctrl`+`h/j/k/l` move between split windows
2024-01-18 15:13:29 +01:00
- `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
2025-01-23 10:38:39 +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
## Buffers
2024-01-18 15:13:29 +01:00
2024-10-21 14:46:23 +02:00
- `leader`+`leader` lists open buffers in `snipe.nvim`
2025-05-20 15:53:29 +02:00
- In snipe.nvim popup: Hit `D` to close the selected buffer
2024-01-18 15:13:29 +01:00
- `:bd` close current buffer
2024-03-05 09:32:10 +01:00
## Text
2024-01-18 15:13:29 +01:00
2025-05-20 15:53:29 +02:00
- `w/e` move to **start/end of next word**
- `b` move to **start of previous word**
2024-02-03 22:14:07 +01:00
- `Ctrl`+`0` start of line
- `Ctrl`+`$` end of line
2024-10-21 14:46:23 +02:00
- `Ctrl`+`d/u` scroll down/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`)
2025-05-20 15:53:29 +02:00
- `s<chars>` highlight jump targets w/ `flash.nvim`
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`+`j/k` scroll down/up through LSP suggestions
- `K` show LSP context info
2024-02-03 22:14:07 +01:00
- `gd` go to definition
2024-03-05 09:32:10 +01:00
- `gr` show references of function
- `grn` renames all refs of the symbol under cursor
- `leader`+`q` toggle `trouble.nvim` quickfix list
2024-02-03 22:14:07 +01:00
- `leader`+`da` go to next diagnostic (any severity)
2025-01-23 10:38:39 +01:00
- `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
2025-01-23 10:38:39 +01:00
- `Ctrl`+`d/u` scroll down/up in preview pane
2024-01-19 08:14:11 +01:00
- `Ctrl`+`/` help
- `Ctrl`+`v` open file in **vertical** split
- `Ctrl`+`x` open file in **horizontal** split
- `Ctrl`+`t` open file in new tab
2024-03-05 09:32:10 +01:00
## Oil
2024-10-21 14:46:23 +02:00
- `Ctrl`+`d/u` bottom/top of file list
2024-03-05 09:32:10 +01:00
- `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/A` insert mode **after the current char**/**at end of line**
- `o/O` insert mode a line **below**/**above** the cursor
2024-01-18 15:13:29 +01:00
- `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
2025-04-28 12:49:21 +02:00
- `yygccp` comment and copy the current line
- `yap` "yank-around-paragraph"
2024-07-30 13:46:57 +02:00
- `yip` "yank-inside-paragraph"
- `yaW` copy word w/ dashes/underscores
2025-01-23 10:38:39 +01:00
- `p/P` paste yanked line below/above
2024-10-21 14:46:23 +02:00
- `:windo diffthis` open `vimdiff` for open splits
2025-01-23 10:38:39 +01:00
- `:vert diffsplit <other/file>` diff this file and `<other/file>`
2024-10-21 14:46:23 +02:00
- `:windo diffoff` to close diff view
2025-05-20 15:53:29 +02:00
- `ciq` change inside quotes w/ `mini.ai`
- `caq` change around quotes w/ `mini.ai`
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-07-30 13:46:57 +02:00
- `vap` "visual-select-around-paragraph"
- `vip` "visual-select-inside-paragraph"
2025-05-20 14:27:32 +02:00
- `ViB` Select lines inside block (useful for commenting)
2024-01-18 15:13:29 +01:00
2024-03-05 09:32:10 +01:00
### Code selection
- `Ctrl`+`s` context-sensitive text selection w/ Tree-sitter
2024-03-05 09:32:10 +01:00
- `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-10-21 14:46:23 +02:00
- `leader`+`e` toggle 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
2024-10-21 14:46:23 +02:00
- `*` search word under cursor
2025-04-28 12:49:21 +02:00
- `Ctrl`+`l` remove search highlight