nvim/KEYMAPS.md
2026-05-19 11:06:48 +05:30

183 lines
4.8 KiB
Markdown

# Neovim Keymaps
**Leader key = `Space`**
---
## File & Buffer
| Key | What it does |
|-----|-------------|
| `<leader>w` | Save the current file |
| `<leader>q` | Quit Neovim |
| `<leader>c` | Close the current buffer |
| `<leader>bc` | Save all buffers, then close everything except the current one |
---
## Navigation
| Key | What it does |
|-----|-------------|
| `e` | Jump to end of line |
| `s` | Jump to first non-blank character of line |
| `cb` | Go back to previous location (like browser back) |
| `cf` | Go forward (undo a `cb`) |
---
## Windows & Splits
| Key | What it does |
|-----|-------------|
| `<leader>v` | Open a vertical split |
| `<leader>h` | Open a horizontal split |
| `Ctrl+h` | Move focus to the left window |
| `Ctrl+j` | Move focus to the window below |
| `Ctrl+k` | Move focus to the window above |
| `Ctrl+l` | Move focus to the right window |
| `Ctrl+Up` | Make current window shorter |
| `Ctrl+Down` | Make current window taller |
| `Ctrl+Left` | Make current window narrower |
| `Ctrl+Right` | Make current window wider |
---
## File Tree (NERDTree)
| Key | What it does |
|-----|-------------|
| `<leader>n` | Show/hide the file explorer sidebar |
---
## Fuzzy Finder (Telescope)
| Key | What it does |
|-----|-------------|
| `<leader>ff` | Search for files by name |
| `<leader>fg` | Search for text inside files (live grep) |
| `<leader>fb` | List all open buffers |
| `<leader>fh` | Search Neovim help topics |
**Inside a Telescope window:**
| Key | What it does |
|-----|-------------|
| `Ctrl+n` | Move to next result |
| `Ctrl+p` | Move to previous result |
| `Ctrl+d` | Delete the selected buffer |
| `Ctrl+c` | Close Telescope |
---
## Clipboard
| Key | What it does |
|-----|-------------|
| `<leader>y` (visual) | Copy selected text to system clipboard |
| `<leader>p` | Paste from system clipboard |
---
## Search
| Key | What it does |
|-----|-------------|
| `<leader>/` | Clear the search highlight |
---
## LSP (Code Intelligence)
| Key | What it does |
|-----|-------------|
| `gd` | Go to the definition of the symbol under cursor |
| `K` | Show documentation for the symbol under cursor |
| `<leader>rn` | Rename the symbol under cursor across the project |
| `gr` | Show all references to the symbol (opens in Trouble panel) |
| `<leader>f` | Format the current file using the LSP |
| `<leader>a` | Show code actions (quick fixes, refactors) |
| `<leader>d` | Show hover documentation (same as `K`) |
---
## Comments (Comment.nvim)
| Key | What it does |
|-----|-------------|
| `<leader>kk` | Toggle comment on the current line |
| `<leader>k` + motion | Comment/uncomment everything the motion covers (e.g. `<leader>k3j` comments 3 lines down) |
| `<leader>k` (visual) | Comment/uncomment the selected lines |
| `<leader>bb` | Toggle block comment on the current line |
| `<leader>b` + motion | Block comment everything the motion covers |
| `<leader>b` (visual) | Block comment the selection |
---
## Diagnostics Panel (Trouble.nvim)
Shows all LSP errors and warnings — across every file the language server knows about, like the Problems panel in VSCode.
| Key | What it does |
|-----|-------------|
| `<leader>xx` | Toggle workspace diagnostics (all errors across the project) |
| `<leader>xd` | Toggle diagnostics for the current file only |
| `<leader>xq` | Open the quickfix list in Trouble |
| `<leader>xl` | Open the location list in Trouble |
**Inside the Trouble panel:**
| Key | What it does |
|-----|-------------|
| `j` / `k` | Move to next / previous item |
| `Enter` or `Tab` | Jump to that error in the file |
| `x` | Open the file in a horizontal split |
| `v` | Open the file in a vertical split |
| `p` | Preview the error location without leaving Trouble |
| `r` | Refresh the list |
| `za` | Toggle fold for a file group |
| `zm` | Collapse all file groups |
| `zr` | Expand all file groups |
| `q` | Close the Trouble panel |
---
## Terminal
| Key | What it does |
|-----|-------------|
| `<leader>t` | Open/close the terminal (toggles a split at the bottom) |
| `<leader>t` (inside terminal) | Close the terminal |
---
## Testing (vim-test)
| Key | What it does |
|-----|-------------|
| `tn` | Run the test nearest to the cursor |
| `tf` | Run all tests in the current file |
| `ts` | Run the entire test suite |
| `tl` | Re-run the last test that was run |
| `tv` | Open the test file that was last run |
---
## Markdown Preview
| Key | What it does |
|-----|-------------|
| `<leader>mp` | Open a browser preview of the current Markdown file |
| `<leader>ms` | Stop the Markdown preview |
| `<leader>mf` | Keep the preview scrolled to where your cursor is |
| `<leader>mt` | Toggle the Markdown preview on/off |
---
## Utilities
| Key | What it does |
|-----|-------------|
| `<leader>sr` | Search and replace (interactive prompt) |
| `<leader>cf` | Create a new Java file |