Vim cheat sheet
nvim config can be found here: https://github.com/mahulst/nvim
Undo mapping in lazy Vim
Two ways to undo current mappings, some mapping come with plugin setup and others are native LazyVim keymaps.
To find which is which use :nmap <Space> (or :vmap g for different mode) and search for the keymap there.
If the key mapping is from a plugin:
-- In plugins.lua
{
"plugin.nvim",
keys = {
"lhs", false
}
}If the plugin is a default LazyVim:
vim.keymap.del("n", "lhs")macro
- Press
qto start and select a key where the macro is stored. - Start recording an action
- Press
qin normal mode to end recording - Run
@<key you selected in step 1>to execute the macro
optionally, append to the recording by pressing q<capital key to append to>
navigation
- Jump forward
<Ctrl-i> - Jump backward
- Jump to last edit position
`. - Jump to last jump in current file
`' - Jump to last yank start / end
`[or`] - Jump to last visual select start / end
`<or`>
delete word under cursor
daw
increment number on line
- increment
<Ctrl-a> - decrement
<Ctrl-x>
Visual mode
change text selection from other side
- after starting selection press
o
selecting inside things
- inside braces
vi{ - inside tags
vit(html <div>select this</div>)
Insert mode
pasting while in insert
- press
<Ctrl-r>"<register to paste>
debugging
q:opens a command line util with vim keys enabled:echo expand('%')to debug certain vim commands that use current file- when debugging a lua function in a key map, put
print("hello, world")anywhere and read the log with:messages
TODO
- How to efficiently do scratch files?
- Intellij http files
- Run jq on current buffer? (like eg. practical vim page 75)