Neovim
Quick notes
Search for Markdown files without leaving the terminal
- Make sure you are in your home directory:
~ - Press
Space + fto search in the current working directory
Open a URL or file in Neovim
gxopens the link with the default system application, usually your configured browser.gfopens a file directly within Neovim.
Preview Markdown in Neovim
Use the command: MarkdownPreview
Return to a suspended Neovim session
- Run
fgin the terminal to resume the suspended Neovim session.
Copilot setup
Configuration file:
~/.config/nvim/lua/custom/plugins.lua
Check notification messages and logs
Use:
:messages
β¨οΈ Neovim keys
A quick-reference cheat sheet for everyday motions, editing, and tooling in Neovim (LazyVim or custom setups).
π§ Motions
π§ LSP and completions
Ctrl + n/Ctrl + pβ navigate suggestions up and down.Tabβ accept the selected suggestion. Do not useEnter, which inserts a new line.K/Shift + kβ show documentation for a function or symbol, such as docstrings.
βοΈ Inserting
[!NOTE] Mode abbreviations: N = Normal mode Β· I = Insert mode Β· T = Terminal mode
| Action | Shortcut (from Normal mode) |
|---|---|
| Append at end of line | Shift + A |
| Insert at beginning of line | Shift + I |
| Open new line below | o |
| Open new line above | Shift + o |
Insert below (same as o) |
o |
π Clipboard and special pastes
gpβ paste below the cursor while keeping the cursor after the pasted text.gPβ paste above the cursor.Alt + hβ move to the start of the line.Alt + lβ move to the end of the line.
πͺ LazyVim and custom leader keys
Leader key: Space
| Shortcut | Action |
|---|---|
<leader> gC |
Create a PR |
<leader> gM |
Merge a PR |
<leader> uC |
Select a colour theme |
<leader> bd |
Delete the current buffer |
Space + fr |
Open recently used files in Telescope |
Space + nΒΉ |
Find files using the classic Telescope mapping |
Ctrl + 6 |
Switch to the last closed buffer or alternate file |
ΒΉ n is an alias for the old Telescope files command.
ποΈ Obsidian.nvim
π Follow a link
- With the cursor on a wiki link, press
Enter(<CR>) to follow it. This works only withobsidian.nvim. - Alternatively, place the cursor inside the parentheses instead of inside the brackets
[], then pressgfto open the file.
Example: a Neovim reference note in the same app notes section.
π§· Create a link
- Type
[[and begin writing the note name. - Select an existing file from the list or choose
(create)to create a new note in your inbox.
β Checkboxes
- Press
Enteron a list item to toggle it into a checkbox. -
Continue pressing
Enterto cycle through states:βx(done) β~(cancelled) β!(important) β>(moved) β(unchecked). -
[ ] test
- [x] new
π§ Normal mode navigation
πΉ Line and character movement
| Motion | Meaning |
|---|---|
$ (or AltGr + 4) |
Go to the end of the line |
0 |
Go to the start of the line |
j / k / h / l |
Down / up / left / right |
5j, 9k β¦ |
Move 5, 9, β¦ lines (prefix with a count) |
2w |
Jump forward 2 words |
2e |
Jump to the end of the second word forward |
% (Shift + 5) |
Jump to the matching bracket |
π§² Search while moving
/β search forward for a pattern.?β search backward for a pattern.nβ move to the next match in the same direction.Nβ move to the previous match in the opposite direction.
βοΈ Quick edits
r<letter>β replace the character under the cursor. For example,rereplaces the current character withe.Rβ enter Replace mode and overwrite characters continuously.ceβ change to the end of the current word.ccβ change the entire line.c$β change from the cursor to the end of the line.
βοΈ Deleting
deβ delete to the end of the current word.d2wβ delete two words forward.d<count><motion>β delete using any motion. For example,d5wdeletes five words.ddβ delete the current line.5ddβ delete five lines.di(,di[,di{β delete everything inside parentheses, brackets, or braces. The cursor can be anywhere inside.
Try it:
- Put the cursor on
3intesting1234567890and pressde. It becomestesting12. - Put the cursor inside
(delete this)and pressdi(. The parentheses remain, but the text is removed.
π Copy and paste
yβ yank (copy). Combine with a motion, such asyiw(yank inner word) oryy(yank the whole line).pβ paste after the cursor or below the current line.Pβ paste before the cursor or above the current line.- Visual mode:
vβ select text βyto yank.
πͺ Folding headings
| Key | Action |
|---|---|
za |
Toggle the fold under the cursor |
zA |
Toggle all folds under the cursor recursively |
zc |
Close the fold |
zo |
Open the fold |
zO |
Open all folds under the cursor |
zR / zi |
Open all folds in the buffer |
zM |
Close all folds in the buffer |
π Search and replacing
Basic commands
:nohl(or:noh) β clear search highlighting until the next search.
| Command | Effect |
|---|---|
:%s/old/new/g |
Replace all occurrences of old with new in the whole file |
:%s/old/new/gc |
Replace all occurrences with confirmation for each match |
/pattern |
Search forward for pattern |
?pattern |
Search backward for pattern |
\vpattern |
βVery magicβ mode: non-alphanumeric characters are treated as special regex characters without escaping |
π Quickly replace the word under the cursor
[!TIP] Use
ciwas an alternative.
- In Normal mode, place the cursor on a word and press
*to search forward for the same word. - Press
Nto return to the previous occurrence if you overshot it, then presscgn. - Type the replacement and press
Esc. - Press
.repeatedly to apply the same change to each next occurrence.
Custom keymap:
Now Ctrl + n on a word starts the βreplace this wordβ flow immediately.
π§ͺ Complex replace examples
Use :s with capture groups \( β¦ \) and the backreference \1.
- Convert
- name: Advanced Programmingβ"Advanced Programming",
- Convert
(e/h)β(y/n)
π§© Miscellaneous tips
vβ enter Visual mode, then move to select text.ggβ go to the first line.Shift + gβ go to the last line.oβ open a line below and enter Insert mode.Oβ open a line above and enter Insert mode.
CodeCompanion.nvim
gaβ accept the changes in CodeCompanion.Ctrl + sβ send the selected lines to the AI.
Commands
/commitis useful for generating a commit message for you.
Octo.nvim
localleader = \
Commenting and using which-key.nvim
- Open the issue with
Space + gi, then presslocalleader + cato access the which-key plugin UI.