- Prefix key (default is
Ctrl + s
): Activates Tmux commands. - Detach session:
Prefix + d
- List sessions:
Prefix + s
- Rename session:
Prefix + $
- New window:
Prefix + c
- Switch window:
Prefix + [window number]
orPrefix + n/p
for next/previous - Split horizontally:
Prefix + "
- Split vertically:
Prefix + %
- Resize pane:
Prefix + arrow keys
- Switch between panes:
Prefix + arrow keys
orPrefix + o
- Close pane:
Prefix + x
- Swap panes:
Prefix + {
orPrefix + }
- Synchronize panes (useful if you want to type in multiple panes at once):
Prefix + :
and typesetw synchronize-panes on
- Enter copy mode:
Prefix + [
- Scroll up/down: Arrow keys or
PgUp
/PgDn
- Exit copy mode:
q
- Copy selection: Press
Space
to start the selection, move the cursor, thenEnter
to copy
- Copy from Tmux to clipboard (requires setup):
Prefix + ]
These are fundamental Vim and Neovim shortcuts that enhance navigation and editing:
- Normal Mode
h
: Move cursor left. - Normal Mode
j
: Move cursor down. - Normal Mode
k
: Move cursor up. - Normal Mode
l
: Move cursor right. - Normal Mode
i
: Enter insert mode. - Normal Mode
v
: Enter visual mode. - Normal Mode
gg
: Go to the top of the file. - Normal Mode
G
: Go to the bottom of the file. - Normal Mode
:w
: Save the current buffer. - Normal Mode
:q
: Quit the current buffer. - Normal Mode
:wq
: Save and quit the current buffer. - Normal Mode
:qa
: Quit all open buffers. - Normal Mode
u
: Undo the last change. - Normal Mode
Ctrl + r
: Redo the last undone change. - Insert Mode
Ctrl + o
: Execute one normal mode command. - Visual Mode
y
: Yank (copy) the selected text. - Visual Mode
d
: Delete the selected text. - Normal Mode
/
: Start a forward search. - Normal Mode
?
: Start a backward search. - Normal Mode
:%s/old/new/g
: Replace all instances of "old" with "new" in the file.
These shortcuts are essential for efficient text editing and navigation within Neovim.
Common Commands for netrw
:e .
or:Ex:
Open the current directory in netrw.-
(while in netrw): Go up one directory level.Enter:
Open the selected file or directory.D:
Delete a file.%:
Create a new file.d:
Create a new directory.r:
Rename a file./filename
To reach the filename.
Here's an explanation of each LSP mapping:
gd
: Go to the definition of the symbol under the cursor, opening the corresponding file and placing the cursor at the definition.K
: Show hover information about the symbol under the cursor, displaying documentation or type information in a floating window.<leader>vws
: Search for a workspace symbol, allowing you to find symbols across the entire workspace.<leader>vd
: Open a floating window displaying diagnostics for the current buffer, helping you quickly identify issues.<leader>vca
: Trigger a code action, which could include fixes or refactoring suggestions based on the current context.<leader>vrr
: Show references to the symbol under the cursor, listing all instances where it is used.<leader>vrn
: Rename the symbol under the cursor, allowing for bulk renaming throughout the workspace.<C-h>
(in insert mode): Display signature help for the function or method under the cursor, showing parameters and documentation.[d
: Jump to the next diagnostic message (like an error or warning) in the buffer.]d
: Jump to the previous diagnostic message in the buffer.
vim.g.mapleader = " "
: Sets the leader key to the spacebar.<leader>pv
: Opens the file explorer (Netrw) in the current directory.- Visual Mode
yyy
: Yanks the selected text into the system clipboard. - Visual Mode
J
: Moves the selected lines down by one and re-selects them. - Visual Mode
K
: Moves the selected lines up by one and re-selects them. - Normal Mode
J
: Joins the current line with the next line while maintaining the cursor position. - Normal Mode
<C-d>
: Scrolls down half a screen and centers the cursor. - Normal Mode
<C-u>
: Scrolls up half a screen and centers the cursor. - Normal Mode
n
: Searches for the next occurrence of the last search and centers the cursor. - Normal Mode
N
: Searches for the previous occurrence of the last search and centers the cursor. - Normal Mode
<leader>zig
: Restarts the LSP server. - Normal Mode
<leader>vwm
: Starts a session with the "vim-with-me" plugin. - Normal Mode
<leader>svwm
: Stops a session with the "vim-with-me" plugin. - Visual Mode
<leader>p
: Pastes the text from the unnamed register while deleting the selection. - Normal/Visual Mode
<leader>y
: Yanks the selected or current line to the system clipboard. - Normal Mode
<leader>Y
: Yanks the entire line to the system clipboard. - Normal/Visual Mode
<leader>d
: Deletes the selected text without affecting the unnamed register. - Insert Mode
<C-c>
: Exits insert mode. - Normal Mode
Q
: Disables theQ
command. - Normal Mode
<C-f>
: Opens a new tmux window with the sessionizer tool. - Normal Mode
<leader>f
: Formats the current buffer using the LSP format command. - Normal Mode
<C-k>
: Navigates to the next quickfix item and centers the cursor. - Normal Mode
<C-j>
: Navigates to the previous quickfix item and centers the cursor. - Normal Mode
<leader>k
: Navigates to the next location in the location list. - Normal Mode
<leader>j
: Navigates to the previous location in the location list. - Normal Mode
<leader>s
: Opens a search-and-replace command for the word under the cursor. - Normal Mode
<leader>x
: Makes the current file executable. - Normal Mode
<leader>ee
: Inserts a basic error handling template in Go. - Normal Mode
<leader>vpp
: Opens the specified Neovim configuration file. - Normal Mode
<leader>mr
: Triggers a "make it rain" animation with the Cellular Automaton plugin. - Normal Mode
<leader><leader>
: Sources the current configuration file, reloading changes.
<C-J>
: Triggers Copilot to accept the currently suggested code completion.
Neovim configuration sets up the vim-fugitive plugin for Git integration. Here's a breakdown of its functionality:
<leader>gs
: Opens the Git command interface.- Autocommand Group:
- When entering a buffer with the filetype
fugitive
, it sets up additional key mappings:<leader>p
: Executesgit push
.<leader>P
: Executesgit pull --rebase
.<leader>t
: Prompts for branch tracking during push.<C-s>
: Executesgit push -u origin
.
- When entering a buffer with the filetype
- Diff Commands:
gu
: Gets changes from the second version.gh
: Gets changes from the third version.
These mappings enhance Git workflow directly within Neovim.
The Harpoon plugin for Neovim helps manage and quickly navigate to files. Here's a breakdown:
<leader>a
: Adds the current file to Harpoon's list.<C-e>
: Toggles the quick menu to navigate between marked files.- File Navigation:
<C-h>
: Navigate to the first marked file.<C-t>
: Navigate to the second marked file.<C-n>
: Navigate to the third marked file.<C-s>
: Navigate to the fourth marked file.
- Replace Marked Files:
<leader><C-h>
: Replace the first marked file.<leader><C-t>
: Replace the second marked file.<leader><C-n>
: Replace the third marked file.<leader><C-s>
: Replace the fourth marked file.
These mappings streamline file management and navigation within your Neovim workflow.
The mapping
configuration sets up key bindings for the completion menu in Neovim using nvim-cmp
during insert mode. Here's what each key does:
<C-p>
: Selects the previous completion item.<C-n>
: Selects the next completion item.<C-y>
: Confirms the selected completion item (if chosen).<C-Space>
: Opens the completion menu to show suggestions.
The code snippet sets up a key mapping in Neovim that allows you to run tests using the Neotest plugin. Here's what it does:
<leader>tc
: When you press this key combination in normal mode, it executes theneotest.run.run()
function, which triggers the running of the current test or all tests associated with the current file.
This mapping makes it convenient to quickly run tests during development.
This code snippet configures the LuaSnip plugin in Neovim, allowing for snippet expansion and navigation. Here’s a breakdown:
- Dependencies: It requires
friendly-snippets
. - Key Mappings:
<C-s>e
: Expands the current snippet.<C-s>;
: Jumps to the next placeholder in the snippet.<C-s>,
: Jumps to the previous placeholder.<C-E>
: Changes the choice in a choice node if one is active.
This setup enhances coding efficiency by streamlining snippet management.
This code configures the Telescope plugin in Neovim, enhancing file searching and navigation capabilities. Key mappings are established:
<leader>pf
: Opens a file finder.<C-p>
: Searches for Git files.<leader>ps
: Greps the word under the cursor.<leader>pWs
: Greps the word (with uppercase).<leader>vh
: Lists help tags.
These mappings streamline file and content searches, improving workflow efficiency in Neovim.
UndoTree is a Neovim plugin that visualizes the undo history of your edits in a tree-like structure. It allows you to see all changes made to a file, including branching paths for when changes are undone and redone. This visual representation helps users navigate through their editing history easily, enabling them to restore previous states or understand the sequence of edits more effectively. Overall, it enhances the standard undo functionality by providing a clearer overview of changes.
It creates a key mapping:
<leader>u
: Toggles the display of the undo tree, allowing you to visualize and navigate through the history of changes made in your files.
This feature helps in efficiently managing and reverting changes.