#cheatsheet
# Neovim Cheatsheet
**LazyVim**: https://www.lazyvim.org/keymaps
**List cheatsheet:**`\?`
### File navigation
| Action | Command |
| -------------------------------------- | -------- |
| Open current directory | `nvim .` |
| Open file explorer | `:Ex` |
| Open file explorer in vertical split | `:Vex` |
| Open file explorer in horizontal split | `:Sex` |
### Windows mode
| Action | Shortcut |
| --------------------------------------- | --------- |
| Open window mode | `ctrl+w` |
| Move around to windows | `h,j,k,l` |
| Open file in vertical split | `v` |
| Open file in horizontal split | `s` |
| Close all splits but the current buffer | `o` |
### Commands
| Action | Command |
| ----------------------------- | ------------------------- |
| Find config path | `:echo stdpath("config")` |
| Show command registry | `:reg` |
| Help | `:h` |
| New tab | `:tabnew` |
| New split of same file | `:split` |
| New split of empty file | `:new` |
| Enable line numbers | `:set nu` |
| Disable line numbers | `:set nu!` |
| Enable relative line numbers | `:set rnu` |
| Disable relative line numbers | `:set rnu!` |
| Expand tab menus | `<C-d>` |
| Cycle forward in tab menus | `<C-n>` |
| Cycle back in tab menu | `<C-p>` |
### Normal Modes
| Action | Shortcut |
| ---- | ---- |
| Left, down, up, right | `h,j,k,l` |
| Forward one word | `w` |
| Back on word | `b` |
| Center on prompt | `zz` |
| Copy line | `yy` |
| Paste line below | `p` |
| Paste line above | `P` |
| Undo | `u` |
| Copy to system clipboard | `"+y` |
| Copy and delete line | `dd` |
| Delete to EOL | `D` |
| Jump to x lines up | `9k` |
| Jump to x lines down | `9j` |
| Go to top of file | `gg` |
| Go to bottom of file | `GG` |
| Delete line and enter insert mode | `cc` |
| Delete char and enter insert mode | `s` |
| Jump to first occurrence of char | `f<char>` |
| Jump forward to next char match | `;` |
| Jump backward to previous char match | `,` |
| Jump up to first occurrence of char | `t<char>` |
| Jump to next paragraph | `}` |
| Jump to previous paragraph | `{` |
| Jump down by half page | `<C-d>` |
| Jump up by half page | `<C-u>` |
| Jump between bracket or curly pairs | `%` |
| Delete up to next curly and insert | `di}` |
| Delete word and insert | `ciw` |
| Delete up to quote | `dt"` |
### Insert Mode
| Action | Shortcut |
| ---------------------------------------------- | -------- |
| Insert before prompt | `i` |
| Insert at first non-space at beginning of line | `I` |
| Insert after prompt | `a` |
| Insert at EOL | `A` |
| Insert new line below | `o` |
| Insert new line above | `O` |
### Find / Replace
| Action | Command |
| ---------------------------------------------------------------------- | --------------------------------------- |
| Search | `:/<searchString>` |
| Remove Highlights | `:nohls` |
| Range Search (Highlight region) | `:'<,'>%s/<searchString>` |
| Single line search and replace | `:/s/<find>/<replace>` |
| Search and replace full file global | `:/%s/<find>/<replace>/g` |
| Search and replace with check | `:/%s/<find>/<replace>/gc` |
| Regex find replace (Finds (foo && bar) and changes it to (bar && foo)) | `:'<,'>s/(\(.*\) && \(.*\)) {\2 \&\& \1}` |
### Macro Mode
| Action | Command |
| ---------------- | ------- |
| Start Macro mode | `q` |
| End Macro mode | `q` |
| Use macro | `@` |
### Neo-Tree
| Action | Command |
| ------ | ------- |
| Close Neo-Tree | :Neotree close |
### Avante
| Action | Shortcut |
|--------------------------------------|------------|
| Show sidebar | `Leader a a` |
| Refresh sidebar | `Leader a r` |
| Switch sidebar focus | `Leader a f` |
| Edit selected blocks | `Leader a e` |
| Choose ours | `c o` |
| Choose theirs | `c t` |
| Choose all theirs | `c a` |
| Choose none | `c 0` |
| Choose both | `c b` |
| Choose cursor | `c c` |
| Move to previous conflict | `] x` |
| Move to next conflict | `[ x` |
| Jump to previous codeblocks (results window) | `[ [` |
| Jump to next codeblocks (results window) | `] ]` |
#### Commands
| Command | Description |
|----------------------------------|-----------------------------------------------------------------------------|
| `:AvanteAsk [question] [position]` | Ask AI about your code. Optional |
| `:AvanteBuild` | Build dependencies for the project |
| `:AvanteChat` | Start a chat session with AI about your codebase. Default is `ask=false` |
| `:AvanteEdit` | Edit the selected code blocks |
| `:AvanteFocus` | Switch focus to/from the sidebar |
| `:AvanteRefresh` | Refresh all Avante windows |
| `:AvanteSwitchProvider` | Switch AI provider (e.g., OpenAI) |
| `:AvanteShowRepoMap` | Show repo map for the project's structure |
| `:AvanteToggle` | Toggle the Avante sidebar |
### Other
| Action | Shortcut |
| ------------- | --------- |
| Terminal | `<C-n>` |
| Switch window | `<C-ww>` |
| Switch tab | `gt` |
### Visual Modes
- Enter visual mode by pressing `v`.
- In this mode you can use navigation controls to highlight text.
- When pasting in visual mode your text will paste where the cursor is.
- Enter visual line mode by pressing `V`.
- In this mode the whole line you are on is highlighted.
- When pasting in visual line mode you text will paste on the next line.
| Action | Shortcut |
| ------------------------------------ | -------- |
| Delete line | `d` |
| Copy line | `y` |
| Paste | `p` |
| Jump between highlight start and end | `o` |
## Harpoon
| Action | Shortcut |
| ---- | ---- |
| Append file to list | `<leader>a` |
| Quick menu | `<C-e>` |
| Jump to list item | `<C-hjkl>` |
## Telescope
https://github.com/nvim-telescope/telescope.nvim
| Action | Shortcut |
| ----------------- | ------------ |
| Find files | `<leader>ff` |
| Live grep | `<leader>fg` |
| Buffers | `<leader>fb` |
| Help | `<leader>fh` |
| Grep files in DIR | `<leader>sG` |
| Search buffer | `<leader>sb` |
| Search keymaps | `<leader>sk` |
## Terminal
| Action | Shortcut |
| ---- | ---- |
| Terminal CWD | `<leader>fT` |
| Terminal Root dir | `<leader>ft` |
| Hide/Show Terminal | `<C-/>` |
## LazyGit
| Action | Shortcut |
| ---- | ---- |
| Lazygit CWD | `<leader>gG` |
| Lazygit Root dir | `<leader>gg` |
## Marking
- Marking allows you to jump to a specific line in a buffer or other file.
- To jump to mark in a buffer use a lower case letter.
- To jump to a mark in another file use an upper case letter.
- To set a mark user `m` followed by a letter.
- To see all marks user `:marks`.
- To jump to a mark use `'` followed by the letter of the mark.
## Config
Source currently opened filed with `:so %`.
nnoremap = normal mode, no remap
inoremap = insert mode, no remap