# Neovim Cheatsheet **LazyVim:** [LazyVim Keymaps](https://www.lazyvim.org/keymaps) ### 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 one 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 | |-------------------|--------------| | Next prompt | `]p` | | Previous prompt | `[p` | | Apply all | `A` | | Apply cursor | `a` | | Retry request | `r` | | Edit request | `e` | | Switch windows | `<Tab>` | | Reverse switch | `<S-Tab>` | | Remove file | `d` | | Add file | `@` | | Close sidebar | `q` | | Show sidebar | `Leaderaa` | | Toggle visibility | `Leaderat` | | Refresh sidebar | `Leaderar` | | Switch focus | `Leaderaf` | ### Suggestion | Action | Shortcut | |--------------------------|----------| | Select model | `Leadera?` | | New ask | `Leaderan` | | Edit selected blocks | `Leaderae` | | Stop AI request | `LeaderaS` | | Select histories | `Leaderah` | | Accept suggestion | `<M-l>` | | Next suggestion | `<M-]>` | | Previous suggestion | `<M-[>` | | Dismiss suggestion | `<C-]>` | | Toggle debug mode | `Leaderad` | | Toggle suggestion display| `Leaderas` | | Toggle repomap | `LeaderaR` | ### Files | Action | Shortcut | |--------------------------------------|-------------| | Add current buffer | `Leaderac` | | Add all buffer files | `LeaderaB` | ### Diff | Action | Shortcut | |------------------------|-----------| | Choose ours | `co` | | Choose theirs | `ct` | | Choose all theirs | `ca` | | Choose both | `cb` | | Choose cursor | `cc` | | Move to next conflict | `]x` | | Move to previous conflict| `[x` | ### Confirm | Action | Shortcut | |------------------------|-----------| | Focus confirm window | `Ctrlwf` | | Confirm code | `c` | | Confirm response | `r` | | Confirm input | `i` | ### Avante Commands | Action | Command | |---------------------------------|-------------------------------------------------| | Ask AI question | `:AvanteAsk [question] [position]` | | Build dependencies | `:AvanteBuild` | | Start chat session | `:AvanteChat` | | Edit code blocks | `:AvanteEdit` | | Switch focus | `:AvanteFocus` | | Refresh windows | `:AvanteRefresh` | | Switch AI provider | `:AvanteSwitchProvider` | | Show repo map | `:AvanteShowRepoMap` | | Toggle sidebar | `:AvanteToggle` | ### Other | Action | Shortcut | |---------------|-----------| | Terminal | `<C-n>` | | Switch window | `<C-ww>` | | Switch tab | `gt` | ### Visual Modes - Enter visual mode by pressing `v`. - Use navigation controls to highlight text. - Paste where the cursor is. - Enter visual line mode by pressing `V`. - Entire line you are on is highlighted. - 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 [GitHub Repository](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 use `m` followed by a letter. - To see all marks use `:marks`. - To jump to a mark use `'` followed by the letter of the mark. ## Config - Source currently opened file with `:so %`. - `nnoremap` = normal mode, no remap. - `inoremap` = insert mode, no remap.