Differences from Vim
Y
Yank to end of line
Neovim maps Y to y$, unlike Vim where it equals yy.
g
c
c
Toggle line comment
g
c
<motion>
Toggle comment over motion
g
O
Outline of symbols / headings
]
d
/
[
d
Next / previous diagnostic
]
q
/
[
q
Next / previous quickfix item
]
b
/
[
b
Next / previous buffer
]
<Space>
/
[
<Space>
Add blank line below / above
]
l
/
[
l
Next / previous location item
]
a
/
[
a
Next / previous argument
Z
R
Restart Neovim (:restart)
*
/
#
Search selected text (visual mode)
In visual mode these search the selection instead of the word.
a
n
/
i
n
Grow visual selection by node
]
n
/
[
n
Visual: next / prev sibling node
LSP
g
r
i
Go to implementation
g
r
t
Go to type definition
Ctrl+]
Go to definition
Works via tagfunc once a server is attached; Ctrl+T jumps
back.
Ctrl+S
Signature help (insert mode)
Ctrl+X
Ctrl+O
LSP completion (insert mode)
g
q
<motion>
Format with the server
Use gw to format with the built-in formatter instead.
:lsp
enable
<name>
Start a configured server
:checkhealth
vim.lsp
Check LSP clients and logs
:lua
vim.lsp.buf.format()
Format the buffer
:lua
vim.lsp.buf.definition()
Go to definition
Minimal LSP setup
vim.lsp.config('lua_ls', { cmd = { 'lua-language-server' }, filetypes = { 'lua' }, root_markers = { '.luarc.json', '.git' },})vim.lsp.enable('lua_ls')
Recipes
Map keys for terminal and windows
vim.keymap.set('t', '<Esc><Esc>', '<C-\\><C-n>')vim.keymap.set('n', '<C-h>', '<C-w>h')vim.keymap.set('n', '<C-l>', '<C-w>l')
Run a command on save
vim.api.nvim_create_autocmd('BufWritePre', { pattern = '*.lua', callback = function() vim.lsp.buf.format() end,})
Per-buffer keys when LSP attaches
vim.api.nvim_create_autocmd('LspAttach', { callback = function(ev) vim.keymap.set('n', 'gd', vim.lsp.buf.definition, { buffer = ev.buf }) end,})
Find a misbehaving setting
nvim --clean file.txt:verbose set formatoptions?:messages