Neovim Cheat Sheet
The key mappings defined in my init.lua, plus built-in Vim commands I keep forgetting. My leader key is the comma (vim.g.mapleader = ","): change that line and every leader mapping moves with it.
Overview
| Keys | Action |
|---|---|
,w |
force-save the buffer (:w!) |
,q |
save and close the window |
,<Space> |
clear search highlighting |
Ctrl-h / Ctrl-j / Ctrl-k / Ctrl-l |
move to the split on the left / below / above / right |
,ev |
open init.lua in a new tab |
,sv |
save and source the config, applying changes at once |
,cv |
close the current tab (the config tab) |
,e |
toggle the nvim-tree file explorer |
,ff |
Telescope: find files by name |
,fg |
Telescope: live grep across the project |
Details
Inside Telescope
Ctrl-n / Ctrl-p move down and up the results; Enter opens the file.
Inside nvim-tree
a adds a file (end the name with / for a directory), d deletes, r renames.
Built-in Commands
- Sort lines: select them with
Shift-v, then:sort(:sort ualso removes duplicates,:sort!reverses). :%s/old/new/gcreplaces in the whole file with confirmation.
Language Servers
The Language Server Protocol (LSP) lets one language server (Ruby LSP, Pyright, gopls) provide completion, diagnostics, go-to-definition and documentation to any editor that speaks the protocol. Neovim has a built-in LSP client: the server runs as a separate process beside the editor and analyses the project.
References
- Neovim documentation: Lua guide, mappings -
vim.keymap.setand leader keys. - Neovim documentation: LSP - the built-in client.
- Language Server Protocol - the specification.
- telescope.nvim on GitHub - pickers and default mappings.
- Programming Languages MOC - hub for language and tooling notes.
Review cards
Flashcard What does `,w` do in Neovim?
It forces the buffer to be saved (:w!).
Flashcard How can you clear search highlighting in Neovim?
Press ,<Space> to clear search highlighting.
Quiz Which key mapping opens `init.lua` in a new tab?
- ,w
- ,q
- ,ev
- ,sv
The ,ev mapping opens init.lua in a new tab.