neovim/CHEATSHEET.md

122 lines
3.8 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
2025-12-04 15:45:02 +01:00
- `:che [<pluginname>]` check base or plugin status
- `:che lsp` show LSP details
- `:verbose set expandtab?` check where `expandtab` was set last
2025-12-10 11:53:58 +01:00
- `:Lazy` package manager
- `:Mason` LSP management
2025-12-04 15:45:02 +01:00
- `:TSUpdate` update Tree-sitter parsers
- `:ConformInfo` Formatter timeout debug
2024-01-19 08:14:11 +01:00
2025-12-04 15:45:02 +01:00
## NAVIGATE
2024-01-18 15:13:29 +01:00
2025-12-04 15:45:02 +01:00
### Windows, splits & tabs
2024-01-18 15:13:29 +01:00
- `Ctrl`+`wq` close window
2025-12-04 15:45:02 +01:00
- `Ctrl`+`ws` split window _horizontally_
- `Ctrl`+`wv` split window _vertically_
- `Ctrl`+`h/j/k/l` move between splits
2024-01-18 15:13:29 +01:00
- `Ctrl`+`w=` equalize split window width and height
- `Ctrl`+`wr` swap position of two windows
2025-12-04 15:45:02 +01:00
- `Ctrl`+`wT` move focused split 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
2025-12-04 15:45:02 +01:00
### Buffers
2024-01-18 15:13:29 +01:00
2025-12-04 15:45:02 +01:00
- `leader`+`leader` lists open buffers [`snipe.nvim`]
2024-01-18 15:13:29 +01:00
- `:bd` close current buffer
2025-12-04 15:45:02 +01:00
### Text
2024-01-18 15:13:29 +01:00
2025-12-04 15:45:02 +01:00
- `w/e` move to _start_/_end_ of _next_ word
- `b` move to _start_ of _previous_ word
- `Ctrl`+`0` _start_ of line
- `Ctrl`+`$` _end_ of line
2025-12-10 11:53:58 +01:00
- `Ctrl`+`d/u` scroll _down_/_up_ 1/2 page keeping the cursor centered
2025-12-04 15:45:02 +01:00
- `Ctrl`+`o` jump to previous location (e.g. after using `gg`)
- `Ctrl`+`i` jump forward (after using `Ctrl`+`o`)
- `s<chars>` highlight jump targets [`flash.nvim`]
2024-02-03 22:14:07 +01:00
2025-12-04 15:45:02 +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
2025-12-04 15:45:02 +01:00
- `Ctrl`+`o` show LSP completion menu in insert mode
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
2025-12-04 15:45:02 +01:00
- `leader`+`q` toggle `trouble.nvim`
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
2025-12-04 15:45:02 +01:00
### Telescope
2024-01-19 08:14:11 +01:00
2025-12-10 11:53:58 +01:00
- `Esc`+`j/k` scroll down/up
2025-01-23 10:38:39 +01:00
- `Ctrl`+`d/u` scroll down/up in preview pane
2025-12-04 15:45:02 +01:00
- `Ctrl`+`v` open file in _vertical_ split
- `Ctrl`+`x` open file in _horizontal_ split
2024-01-19 08:14:11 +01:00
- `Ctrl`+`t` open file in new tab
2025-12-04 15:45:02 +01:00
### Oil
2024-03-05 09:32:10 +01:00
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
2025-12-04 15:45:02 +01:00
- `Ctrl`+`v` open file in _vertical_ split
- `Ctrl`+`x` open file in _horizontal_ split
2024-03-05 09:32:10 +01:00
- `Ctrl`+`t` open file in new tab
2025-12-04 15:45:02 +01:00
### Snipe
2024-01-18 15:13:29 +01:00
2025-12-04 15:45:02 +01:00
- `D` close selected buffer
2024-01-18 15:13:29 +01:00
2025-12-04 15:45:02 +01:00
## SELECT, DELETE AND CHANGE TEXT
2024-03-05 09:32:10 +01:00
2025-12-04 15:45:02 +01:00
Prefix the marked commands below with `v` to select, `d` for deleting or `c` to
change.
2024-01-18 15:13:29 +01:00
2025-12-04 15:45:02 +01:00
- `leader`+`o` re-format whole file or visual [`conform.nvim`]
- `i/I` insert mode at _cursor position_/_beginning of the line_
- `a/A` insert mode _after the current char_/_at end of line_
- `o/O` insert mode a line _below_/_above_ the cursor
2025-12-10 11:53:58 +01:00
- `cc/S` replace _whole_ line
- `C` _replace_ to the _end_ of the line _from current position_
2025-12-04 15:45:02 +01:00
- `D` _delete_ to the end of the line
- `p/P` paste yanked line below/above
- `yygccp` comment and copy the current line
- `<prefix>$` ... to the end of the _line_
- `<prefix>w` ... to the end of current _word_
- `<prefix>ap` ... around _paragraph_
- `<prefix>ip` ... inside _paragraph_
- `<prefix>at` ... around HTML/XML _tag_
- `<prefix>it` ... inside HTML/XML _tag_
- `<prefix>iq` ... inside _quotes_ [`mini.ai`]
- `<prefix>aq` ... around _quotes_ [`mini.ai`]
- `<prefix>aW` ... word with dashes or underscores
### Selection-only commands
2024-01-18 15:13:29 +01:00
2025-05-20 14:27:32 +02:00
- `ViB` Select lines inside block (useful for commenting)
2025-12-04 15:45:02 +01:00
- `Ctrl`+`s` context-sensitive text selection (Tree-sitter)
- `Backspace` reduce context-sensitive selection
2024-01-18 15:13:29 +01:00
2025-12-04 15:45:02 +01:00
## GIT
2024-03-05 09:32:10 +01:00
2025-12-04 15:45:02 +01:00
- `:windo diffthis` open `vimdiff` for open splits
- `:vert diffsplit <other/file>` diff this file and `<other/file>`
- `:windo diffoff` to close diff view
2024-03-05 09:32:10 +01:00
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