- Basic Movement
- Inserting & Editing
- Copy & Paste
- Undo & Redo
- Visual Mode
- Search & Replace
- Navigation
- LSP & Completion
- Useful Commands
- File & Buffer Management
- Tabs
- Customization
- Plugin Management
Basic Movement
Command | Description | Real-World Example |
---|---|---|
h / l |
Move left/right by one character |
Input: h Effect: Cursor moves one character to the left |
j / k |
Move down/up by one line |
Input: j Effect: Cursor moves one line down |
w / b |
Jump forward/backward to the start of the next/previous word |
Input: w Effect: Cursor jumps to the next word |
e |
Jump to the end of the current/next word |
Input: e Effect: Cursor jumps to the end of the current/next word |
0 |
Move to the beginning of the line |
Input: 0 Effect: Cursor moves to the first column of the current line |
^ |
Move to the first non-blank character of the line |
Input: ^ Effect: Cursor jumps to the first word of the current line |
$ |
Move to the end of the line |
Input: $ Effect: Cursor jumps to the last character of the current line |
{ / } |
Move to the beginning of the previous/next paragraph |
Input: } Effect: Cursor moves to the start of the next paragraph |
/pattern / ?pattern |
Search forward/backward for a pattern |
Input: /function Effect: Cursor jumps to the next occurrence of "function" |
n / N |
Repeat last search forward/backward |
Input: n Effect: Jumps to next match of last search |
Inserting & Editing
Command | Description | Real-World Example |
---|---|---|
i |
Insert before the cursor |
Input: iHello Effect: Inserts "Hello" before cursor position |
I |
Insert at the beginning of the line |
Input: IHello Effect: Inserts "Hello" at the start of the current line |
a |
Insert after the cursor |
Input: aWorld Effect: Inserts "World" just after the current character |
A |
Insert at the end of the line |
Input: A! Effect: Appends "!" at the end of the current line |
o |
Open a new line below and insert |
Input: oNew line Effect: Creates a new line below and starts inserting "New line" |
O |
Open a new line above and insert |
Input: OHeader Effect: Adds "Header" on a new line above the current one |
x |
Delete character under the cursor |
Input: x Effect: Deletes the current character |
dd |
Delete the current line |
Input: dd Effect: Removes the entire line where the cursor is |
dw |
Delete from cursor to end of word |
Input: dw Effect: Deletes current word (or part of it) starting from cursor |
d$ |
Delete from cursor to end of line |
Input: d$ Effect: Deletes all text from cursor to line end |
D |
Same as d$ |
Input: D Effect: Deletes everything to the right of the cursor |
cw |
Change word (delete and enter insert mode) |
Input: cwHello Effect: Replaces the current word with "Hello" |
cc |
Change the whole line |
Input: ccHello World Effect: Replaces the entire line with "Hello World" |
C |
Change from cursor to end of line |
Input: CHi! Effect: Changes from current position to end of line to "Hi!" |
s |
Substitute character under cursor |
Input: sA Effect: Replaces current character with "A" |
r |
Replace a single character |
Input: rX Effect: Replaces current character with "X" |
R |
Enter replace mode until <Esc> |
Input: RHELLO |
Copy & Paste
Command | Description | Real-World Example |
---|---|---|
yy |
Yank (copy) the current line |
Input: yy Effect: Copies the entire line into default register |
yw |
Yank from cursor to end of the current word |
Input: yw Effect: Copies the current word from cursor position |
y$ |
Yank from cursor to end of line |
Input: y$ Effect: Copies text from cursor to the end of line |
Y |
Yank the entire line (same as yy ) |
Input: Y Effect: Copies the whole line |
p |
Paste after the cursor or below the line |
Input: p Effect: Pastes yanked content after cursor or below the line |
P |
Paste before the cursor or above the line |
Input: P Effect: Pastes yanked content before cursor or above the line |
"aY |
Yank current line into register “a” |
Input: "aY Effect: Saves the current line into register a |
"ap |
Paste from register “a” |
Input: "ap Effect: Pastes content stored in register a |
Undo & Redo
Command | Description | Real-World Example |
---|---|---|
u |
Undo the last change |
Input: u Effect: Reverts your most recent edit (e.g., undo inserted text) |
<C-r> |
Redo the change that was just undone |
Input: Ctrl + r
Effect: Restores the change you just undid using
|
Visual Mode
Command | Description | Real-World Example |
---|---|---|
v |
Enter visual mode (character-wise selection) |
Input: v (then move with arrows or hjkl) Effect: Highlights characters one by one |
V |
Enter linewise visual mode |
Input: V Effect: Selects entire lines |
<C-v> |
Enter block visual mode (column-wise) |
Input: Ctrl + v (then move to select block) Effect: Highlights a rectangular block of text |
y |
Yank the selected text |
Input: v (select) → y Effect: Copies the selected area |
d |
Delete the selected text |
Input: V (select lines) → d Effect: Deletes selected lines |
p |
Paste over the selection |
Input: Select text → p Effect: Replaces selection with yanked text |
: |
Run a command on the selected text |
Input: v (select) → :sort Effect: Sorts the selected lines |
Search & Replace
Command | Description | Real-World Example |
---|---|---|
/pattern |
Search forward for a pattern |
Input: /error Effect: Highlights and jumps to the next occurrence of "error" |
?pattern |
Search backward for a pattern |
Input: ?function Effect: Searches up the file for "function" |
n |
Repeat the last search in the same direction |
Input: n Effect: Jumps to the next match of the last search |
N |
Repeat the last search in the opposite direction |
Input: N Effect: Jumps to the previous match of the last search |
:%s/old/new/g |
Replace all occurrences of “old” with “new” in the whole file |
Input: :%s/bug/fix/g Effect: Replaces all instances of "bug" with "fix" |
:s/this/that/gc |
Replace “this” with “that” on the current line, confirming each |
Input: :s/error/warning/gc Effect: Prompts before replacing each "error" with "warning" on current line |
Command | Description | Real-World Example |
---|---|---|
:e filename |
Edit/open a file |
Input: :e notes.txt Effect: Opens "notes.txt" in the current window |
:Ex / :Explore |
Open file explorer |
Input: :Ex Effect: Opens a split file explorer in the current directory |
:ls |
List all open buffers |
Input: :ls Effect: Shows all currently open files (buffers) |
:bnext |
Go to next buffer |
Input: :bnext Effect: Switches to the next file in the buffer list |
:bprev |
Go to previous buffer |
Input: :bprev Effect: Switches to the previous file in the buffer list |
:bd |
Delete/close a buffer |
Input: :bd Effect: Closes the current buffer |
<C-w>v |
Split window vertically |
Input: Ctrl + w, then v Effect: Opens a vertical split |
<C-w>s |
Split window horizontally |
Input: Ctrl + w, then s Effect: Opens a horizontal split |
<C-w>h/j/k/l |
Move between windows |
Input: Ctrl + w, then l Effect: Moves to the window on the right |
:tabnew |
Open a new tab |
Input: :tabnew Effect: Opens a new empty tab |
gt |
Go to next tab |
Input: gt Effect: Switches to the next tab |
gT |
Go to previous tab |
Input: gT Effect: Switches to the previous tab |
LSP & Completion
Command | Description | Real-World Example |
---|---|---|
gd |
Go to definition of symbol |
Input: gd Effect: Jumps to the function or variable definition under the cursor |
K |
Show hover documentation |
Input: K Effect: Shows documentation for the symbol under the cursor |
<leader>rn |
Rename symbol |
Input: <leader>rn Effect: Prompts to rename the variable or function under cursor |
:lua vim.lsp.buf.format() |
Format current buffer using LSP |
Input: :lua vim.lsp.buf.format() Effect: Formats the file according to language server rules |
Useful Commands
Command | Description | Real-World Example |
---|---|---|
:w |
Save the current file |
Input: :w Effect: Saves the current file |
:q |
Quit Neovim |
Input: :q Effect: Exits Neovim (only works if no changes are unsaved) |
:wq |
Save and quit Neovim |
Input: :wq Effect: Saves the file and exits Neovim |
:x |
Save and quit (same as :wq) |
Input: :x Effect: Saves the file and exits (same as :wq) |
:q! |
Quit without saving (force quit) |
Input: :q! Effect: Exits without saving changes, even if unsaved modifications exist |
:!command |
Execute an external command |
Input: :!ls Effect: Runs the "ls" command in the terminal and displays the output inside Neovim |
:noh |
Clear search highlighting |
Input: :noh Effect: Clears any active search highlighting |
:set paste |
Enable paste mode (useful when pasting text) |
Input: :set paste Effect: Temporarily disables automatic indentation and formatting, ideal for pasting text |
File & Buffer Management
Command | Description | Real-World Example |
---|---|---|
:e filename |
Open a file for editing |
Input: :e example.txt Effect: Opens "example.txt" in the current window for editing |
:w |
Save the current file |
Input: :w Effect: Saves the changes made to the current file |
:q |
Quit Neovim |
Input: :q Effect: Exits Neovim (only works if no changes are unsaved) |
:ls |
List all open buffers |
Input: :ls Effect: Displays a list of all open buffers in Neovim |
:bnext |
Switch to the next buffer |
Input: :bnext Effect: Switches to the next buffer in the buffer list |
:bprev |
Switch to the previous buffer |
Input: :bprev Effect: Switches to the previous buffer in the buffer list |
:bd |
Close the current buffer |
Input: :bd Effect: Closes the current buffer (file) |
:b |
Switch to a specific buffer by its number |
Input: :b 2 Effect: Switches to the second buffer in the list |
:sp |
Split the window horizontally and load a file |
Input: :sp example.txt Effect: Opens "example.txt" in a horizontal split |
:vsp |
Split the window vertically and load a file |
Input: :vsp example.txt Effect: Opens "example.txt" in a vertical split |
Window Management
Command | Description | Real-World Example |
---|---|---|
<C-w>v |
Split the window vertically |
Input: <C-w>v Effect: Splits the current window into two vertical panes |
<C-w>s |
Split the window horizontally |
Input: <C-w>s Effect: Splits the current window into two horizontal panes |
<C-w>h/j/k/l |
Navigate between windows using directional keys |
Input: <C-w>h (move left window) <C-w>j (move down window) <C-w>k (move up window) <C-w>l (move right window) Effect: Moves the cursor to the respective window |
<C-w>q |
Close the current window |
Input: <C-w>q Effect: Closes the current window, leaving the other panes open |
<C-w>w |
Switch to the next window |
Input: <C-w>w Effect: Cycles to the next window in the current layout |
<C-w>H |
Move the current window to the far left |
Input: <C-w>H Effect: Moves the current window to the far left of the layout |
<C-w>J |
Move the current window to the bottom |
Input: <C-w>J Effect: Moves the current window to the bottom of the layout |
<C-w>K |
Move the current window to the top |
Input: <C-w>K Effect: Moves the current window to the top of the layout |
<C-w>L |
Move the current window to the far right |
Input: <C-w>L Effect: Moves the current window to the far right of the layout |
Tabs
Command | Description | Real-World Example |
---|---|---|
:tabnew |
Open a new tab page |
Input: :tabnew Effect: Opens a new tab page (creates a new workspace) |
gt |
Switch to the next tab |
Input: gt Effect: Switches to the next tab in the tab list |
gT |
Switch to the previous tab |
Input: gT Effect: Switches to the previous tab in the tab list |
:tabn |
Go to the next tab |
Input: :tabn Effect: Switches to the next tab |
:tabp |
Go to the previous tab |
Input: :tabp Effect: Switches to the previous tab |
:tabnew filename |
Open a file in a new tab |
Input: :tabnew example.txt Effect: Opens "example.txt" in a new tab |
:tabclose |
Close the current tab |
Input: :tabclose Effect: Closes the current tab (and all its windows) |
Customization
Command | Description | Real-World Example |
---|---|---|
:set number |
Enable line numbering |
Input: :set number Effect: Displays line numbers in the left margin |
:set relativenumber |
Enable relative line numbering |
Input: :set relativenumber Effect: Displays line numbers relative to the cursor position |
:set hlsearch |
Highlight search results |
Input: :set hlsearch Effect: Highlights all matches for the search pattern |
:set incsearch |
Enable incremental search |
Input: :set incsearch Effect: Shows search results as you type |
:set ignorecase |
Enable case-insensitive search |
Input: :set ignorecase Effect: Makes search patterns case-insensitive |
:set smartcase |
Enable smart case search |
Input: :set smartcase Effect: Enables case-sensitive search only when uppercase characters are used in the pattern |
:set tabstop=4 |
Set tab width to 4 spaces |
Input: :set tabstop=4 Effect: Sets the tab width to 4 spaces |
:set shiftwidth=4 |
Set the number of spaces to use for indentation |
Input: :set shiftwidth=4 Effect: Sets the indentation width to 4 spaces |
:set expandtab |
Convert tabs to spaces |
Input: :set expandtab Effect: Converts tabs to spaces when pressing the Tab key |
Plugin Management
Command | Description | Real-World Example |
---|---|---|
:PlugInstall |
Install plugins with vim-plug |
Input: :PlugInstall Effect: Installs all plugins listed in the vim-plug plugin manager configuration |
:PlugUpdate |
Update installed plugins |
Input: :PlugUpdate Effect: Updates all installed plugins to the latest version |
:PlugClean |
Remove unused plugins |
Input: :PlugClean Effect: Removes plugins that are no longer listed in the vim-plug configuration |
:PluginInstall |
Install plugins with Pathogen |
Input: :PluginInstall Effect: Installs plugins defined in the Pathogen configuration |
:PluginUpdate |
Update plugins with Pathogen |
Input: :PluginUpdate Effect: Updates all plugins installed via Pathogen |
:PackerSync |
Sync and update plugins with Packer |
Input: :PackerSync Effect: Installs, updates, and removes plugins defined in the Packer configuration |