3.8 KiB
3.8 KiB
Neovim cheat sheet
Heavily customized. Related blog post: https://lugh.ch/neovim-lessons-learned.html
BASICS
:che [<pluginname>]check base or plugin status:che lspshow LSP details:verbose set expandtab?check whereexpandtabwas set last:Lazypackage manager:MasonLSP management:TSUpdateupdate Tree-sitter parsers:ConformInfoFormatter timeout debug
NAVIGATE
Windows, splits & tabs
Ctrl+wqclose windowCtrl+wssplit window horizontallyCtrl+wvsplit window verticallyCtrl+h/j/k/lmove between splitsCtrl+w=equalize split window width and heightCtrl+wrswap position of two windowsCtrl+wTmove focused split to new tabgtorgTswitch forward/reverse between tabs
Buffers
leader+leaderlists open buffers [snipe.nvim]:bdclose current buffer
Text
w/emove to start/end of next wordbmove to start of previous wordCtrl+0start of lineCtrl+$end of lineCtrl+d/uscroll down/up 1/2 page keeping the cursor centeredCtrl+ojump to previous location (e.g. after usinggg)Ctrl+ijump forward (after usingCtrl+o)s<chars>highlight jump targets [flash.nvim]
LSP, Code & Diagnostics
Ctrl+j/kscroll down/up through LSP suggestionsKshow LSP context infoCtrl+oshow LSP completion menu in insert modegdgo to definitiongrshow references of functiongrnrenames all refs of the symbol under cursorleader+qtoggletrouble.nvimleader+dago to next diagnostic (any severity)leader+dwgo to next diagnostic (warning severity)leader+dego to next diagnostic (error severity)
Telescope
Esc+j/kscroll down/upCtrl+d/uscroll down/up in preview paneCtrl+vopen file in vertical splitCtrl+xopen file in horizontal splitCtrl+topen file in new tab
Oil
Ctrl+d/ubottom/top of file listCtrl+ppreview fileCtrl+vopen file in vertical splitCtrl+xopen file in horizontal splitCtrl+topen file in new tab
Snipe
Dclose selected buffer
SELECT, DELETE AND CHANGE TEXT
Prefix the marked commands below with v to select, d for deleting or c to
change.
leader+ore-format whole file or visual [conform.nvim]i/Iinsert mode at cursor position/beginning of the linea/Ainsert mode after the current char/at end of lineo/Oinsert mode a line below/above the cursorcc/Sreplace whole lineCreplace to the end of the line from current positionDdelete to the end of the linep/Ppaste yanked line below/aboveyygccpcomment 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
ViBSelect lines inside block (useful for commenting)Ctrl+scontext-sensitive text selection (Tree-sitter)Backspacereduce context-sensitive selection
GIT
:windo diffthisopenvimdifffor open splits:vert diffsplit <other/file>diff this file and<other/file>:windo diffoffto close diff view
SEARCH/OPEN
leader+fgsearch text in files (also searches for text under cursor)leader+ffsearch files (respects.gitignore)leader+etoggle Oil file explorerleader+forecently opened filesgfopen file under cursor in a new buffergxopen link under cursor in default browser*search word under cursorCtrl+lremove search highlight