3.9 KiB
3.9 KiB
Neovim cheat sheet
Heavily customized. Related blog post: https://lugh.ch/neovim-lessons-learned.html
BASICS
:checkhealth [<pluginname>]check base or plugin status:checkhealth vim.lspshow details of LSP attached to buffer:verbose set expandtab?check whereexpandtabhas been set last:Lazyshow package manager TUI:Masonshow LSP management TUI:TSUpdateupdate all Tree-sitter parsers:ConformInfouseful to debug why a formatter times out
NAVIGATING
Windows, splits & tabs
Ctrl+wqclose windowCtrl+wssplit window horizontallyCtrl+wvsplit window verticallyCtrl+h/j/k/lmove between split windowsCtrl+w=equalize split window width and heightCtrl+wrswap position of two windowsCtrl+wTmove active split window to new tabgtorgTswitch forward/reverse between tabs
Buffers
leader+leaderlists open buffers insnipe.nvim- In snipe.nvim popup: Hit
Dto close the selected buffer :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 while keeping the cursor centeredCtrl+ojump to location you were before (e.g. after usinggg)Ctrl+ijump back to location you were before (after usingCtrl+o)s<chars>highlight jump targets w/flash.nvim
LSP, Code & Diagnostics
Ctrl+j/kscroll down/up through LSP suggestionsKshow LSP context infogdgo to definitiongrshow references of functiongrnrenames all refs of the symbol under cursorleader+qtoggletrouble.nvimquickfix listleader+dago to next diagnostic (any severity)leader+dwgo to next diagnostic (warning severity)leader+dego to next diagnostic (error severity)
Telescope
↓orCtrl+nscroll down (next) file list↑orCtrl+pscroll up (previous) file listCtrl+d/uscroll down/up in preview paneCtrl+/helpCtrl+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
EDITING
Code editing
leader+ore-format whole file or visual w/conform.nvimiinsert mode at cursor positionIinsert mode at beginning of linea/Ainsert mode after the current char/at end of lineo/Oinsert mode a line below/above the cursorcwreplace the current wordccreplace whole lineCreplace to the end of the lineyycopy the current lineyygccpcomment and copy the current lineyap"yank-around-paragraph"yip"yank-inside-paragraph"yaWcopy word w/ dashes/underscoresp/Ppaste yanked line below/above:windo diffthisopenvimdifffor open splits:vert diffsplit <other/file>diff this file and<other/file>:windo diffoffto close diff viewciqchange inside quotes w/mini.aicaqchange around quotes w/mini.ai
SELECTING
Visual mode
vat cursor positionVline modeCtrl+vblock modevap"visual-select-around-paragraph"vip"visual-select-inside-paragraph"ViBSelect lines inside block (useful for commenting)
Code selection
Ctrl+scontext-sensitive text selection w/ Tree-sitterBackspacereduce context-sensitive selection
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