Introduction to Neovim Keyboard Shortcuts
Neovim is a hyper-extensible text editor built on the foundation of Vim, designed for developers who want efficiency, speed, and complete control over their editing environment. At its core, Neovim's power comes from its keyboard-driven workflow โ a rich set of keyboard shortcuts that allow you to navigate, edit, and manipulate text without ever reaching for the mouse. This guide provides a complete reference to Neovim keyboard shortcuts, from basic movements to advanced window management, along with practical examples and best practices for integrating them into your daily workflow.
What Are Neovim Keyboard Shortcuts?
Neovim keyboard shortcuts are mnemonic key sequences that execute specific actions within the editor. Unlike traditional text editors that rely on modifier-heavy combinations (Ctrl+C, Ctrl+V), Neovim uses a modal system where the same key can perform different actions depending on the active mode. Most shortcuts are designed to be composable โ you can combine movement commands with actions to create precise, efficient editing operations. For example, d3w means "delete three words," combining the delete action (d) with a motion (3w).
The shortcut system is built on three pillars: modes that define the context, operators that define the action, and motions that define the range. Understanding how these interact is the key to mastering Neovim.
Why Keyboard Shortcuts Matter in Neovim
Mastering Neovim shortcuts transforms your editing experience in several profound ways:
- Speed: Every operation becomes nearly instantaneous when your hands never leave the home row. What takes multiple mouse clicks and menu navigations in other editors becomes a few keystrokes.
- Reduced strain: Eliminating the mouse reduces repetitive strain from constant hand movement between keyboard and mouse.
- Composability: Shortcuts combine like a language. Once you learn a motion and an operator, you can combine them in countless ways without memorizing each combination separately.
- Precision: Text objects and motions allow surgical edits that would be cumbersome with mouse selection.
- Flow state: The modal editing model keeps you in a rhythm of thinking and executing, reducing context-switching overhead.
Understanding Neovim Modes
Before diving into specific shortcuts, you must understand the modal nature of Neovim. Each mode defines which shortcuts are available:
Normal Mode
This is the default mode when you open Neovim. In Normal mode, every key is a command โ letters don't insert text, they trigger actions. You return to Normal mode from any other mode by pressing Esc or Ctrl+[. This is where you navigate, manipulate text, and chain commands.
Insert Mode
Entered by pressing i, a, o, or other insertion commands. In Insert mode, typing inserts characters normally, like a conventional editor. Press Esc to return to Normal mode.
Visual Mode
Entered by pressing v (character-wise), V (line-wise), or Ctrl+v (block-wise). Visual mode highlights a selection that can then be operated on with commands like d (delete), y (yank/copy), or c (change).
Command Mode
Entered by pressing : from Normal mode. Command mode lets you execute Ex commands like :w (write), :q (quit), :s/pattern/replacement/g (substitute), and many more.
Replace Mode
Entered by pressing R from Normal mode. Each character you type replaces the character under the cursor, continuing until you press Esc.
Essential Movement Shortcuts
Movement is the foundation of efficient editing. These shortcuts keep your hands on the home row:
Basic Character Movement
h Move cursor left
j Move cursor down
k Move cursor up
l Move cursor right
The hjkl keys replace the arrow keys. With practice, this becomes second nature and eliminates the need to move your hand to the arrow cluster.
Word Movement
w Move to the beginning of the next word
W Move to the beginning of the next WORD (whitespace-separated)
b Move to the beginning of the previous word
B Move to the beginning of the previous WORD
e Move to the end of the current/next word
E Move to the end of the current/next WORD
ge Move backward to the end of the previous word
The distinction between "word" and "WORD" is important: a word stops at punctuation boundaries (foo.bar is two words), while a WORD only stops at whitespace (foo.bar is one WORD).
Line Movement
0 Move to the first character of the line
^ Move to the first non-whitespace character of the line
$ Move to the end of the line
gg Move to the beginning of the file
G Move to the end of the file
{ Move to the previous blank line (paragraph boundary)
} Move to the next blank line (paragraph boundary)
Screen Movement
H Move to the top of the visible screen
M Move to the middle of the visible screen
L Move to the bottom of the visible screen
zt Scroll so the current line is at the top of the screen
zz Scroll so the current line is at the center of the screen
zb Scroll so the current line is at the bottom of the screen
Ctrl+f Scroll forward one full screen
Ctrl+b Scroll backward one full screen
Ctrl+d Scroll forward half a screen
Ctrl+u Scroll backward half a screen
Precise Jumps
f{char} Move forward to the next occurrence of {char} on the current line
F{char} Move backward to the previous occurrence of {char} on the current line
t{char} Move forward to just before the next occurrence of {char}
T{char} Move backward to just after the previous occurrence of {char}
; Repeat the last f, F, t, or T command forward
, Repeat the last f, F, t, or T command backward
For example, f( jumps to the next open parenthesis. t) jumps to just before the next closing parenthesis โ perfect for deleting everything up to a character.
Jump List and Marks
Ctrl+o Go back to the previous location in the jump list
Ctrl+i Go forward in the jump list
m{a-z} Set a mark (a through z) at the current cursor position
`{mark} Jump to the exact position of a mark
'{mark} Jump to the beginning of the line containing a mark
`` Jump back to the position before the last jump
'' Jump back to the line before the last jump
Editing Shortcuts in Normal Mode
These are the operators that modify text. Each can be combined with motions or text objects:
Core Operators
d{motion} Delete from cursor to {motion} and copy to register
c{motion} Change (delete and enter Insert mode) from cursor to {motion}
y{motion} Yank (copy) from cursor to {motion}
p Paste after the cursor
P Paste before the cursor
x Delete the character under the cursor
X Delete the character before the cursor
s Substitute character (delete under cursor and enter Insert mode)
S Substitute entire line (delete line and enter Insert mode)
r{char} Replace the character under the cursor with {char}
. Repeat the last change at the current cursor position
Practical Operator + Motion Examples
d3w Delete three words forward
c2b Change two words backward (delete and start inserting)
y$ Yank from cursor to end of line
d/foo Delete from cursor until the next occurrence of "foo"
c/bar Change from cursor until the next occurrence of "bar"
d f) Delete up to and including the next closing parenthesis
c t, Change up to (but not including) the next comma
Line-Based Editing
dd Delete the current line
cc Change the current line (delete and enter Insert mode)
yy Yank the current line
Y Yank the current line (same as yy)
D Delete from cursor to end of line
C Change from cursor to end of line
2dd Delete two lines (current and next)
5yy Yank five lines
The Dot Command (Repeat)
The . command is one of the most powerful features in Neovim. It repeats the last change โ not just the last keystroke, but the entire change operation. This means if you delete a word with daw, pressing . will delete the word under the cursor again. If you change "foo" to "bar" inside quotes with ci"bar, pressing . at another quoted string will change its contents to "bar". This encourages you to make repeatable, atomic edits.
Text Objects: The Power of Structured Editing
Text objects are predefined regions of text that you can operate on. They are the secret to incredibly precise editing:
Word Text Objects
iw Inner word (the word under cursor, excluding surrounding whitespace)
aw A word (the word plus trailing/leading whitespace)
iW Inner WORD (whitespace-delimited)
aW A WORD (plus surrounding whitespace)
Delimiter Text Objects
i" Inner double-quoted string (inside the quotes)
a" A double-quoted string (including the quotes)
i' Inner single-quoted string
a' A single-quoted string (including the quotes)
i( i) Inner parentheses (inside the parens)
a( a) A parenthesized block (including the parens)
i[ i] Inner brackets
a[ a] A bracketed block (including brackets)
i{ i} Inner braces
a{ a} A braced block (including braces)
it Inner XML/HTML tag block
at A tag block (including the tags)
Block Text Objects
ip Inner paragraph
ap A paragraph (including surrounding blank lines)
is Inner sentence
as A sentence (including trailing space)
Combining Operators with Text Objects
ciw Change inner word (replace the word under cursor)
daw Delete a word (word plus whitespace, properly spacing)
yi" Yank inner double-quoted string
ca{ Change a braced block (delete contents plus braces, enter Insert)
da( Delete a parenthesized block (contents plus parens)
cip Change inner paragraph
yit Yank inner HTML tag contents
cit Change inner HTML tag contents
The difference between i (inner) and a (a/around) is crucial: ciw changes just the word, leaving surrounding whitespace intact, while caw also removes the trailing whitespace. Similarly, ci" changes text inside quotes, while ca" also removes the quotes themselves.
Insert Mode Shortcuts
While in Insert mode, these shortcuts provide quick access to common operations without leaving Insert mode:
Ctrl+h Delete the character before the cursor (backspace)
Ctrl+w Delete the word before the cursor
Ctrl+u Delete everything from cursor to the beginning of the line
Ctrl+t Indent the current line (insert shiftwidth spaces)
Ctrl+d Dedent the current line
Ctrl+r{register} Insert the contents of {register} (e.g., Ctrl+r" for last yank)
Ctrl+r= Insert the result of an expression (opens expression prompt)
Ctrl+o{command} Execute one Normal mode command and return to Insert mode
Ctrl+v{char} Insert a literal character (bypassing digraphs/abbreviations)
Ctrl+k{char1}{char2} Insert a digraph (e.g., Ctrl+k'o inserts รด)
The Ctrl+o escape is particularly useful: Ctrl+o d3w deletes three words forward while staying in Insert mode.
Entering Insert Mode
i Insert before the cursor
I Insert at the beginning of the line
a Append after the cursor
A Append at the end of the line
o Open a new line below and enter Insert mode
O Open a new line above and enter Insert mode
gi Return to the last Insert mode position and enter Insert mode
gI Insert at the beginning of the line (column 1, ignoring indentation)
Visual Mode Shortcuts
Visual mode lets you visually select text before operating on it. It's great for ad-hoc selections that don't map neatly to text objects:
Entering Visual Mode
v Enter character-wise Visual mode
V Enter line-wise Visual mode
Ctrl+v Enter block-wise Visual mode
gv Reselect the last visual selection
o In Visual mode: move cursor to the opposite end of the selection
Block Visual Mode Operations
Block visual mode (Ctrl+v) is uniquely powerful for columnar editing:
# After selecting a rectangular block with Ctrl+v:
I{text}Esc Insert {text} at the beginning of each selected line
A{text}Esc Append {text} to the end of each selected line
c{text}Esc Change each line in the block to {text}
d Delete the selected block
> Shift the block right (indent)
< Shift the block left (dedent)
r{char} Replace every character in the block with {char}
Example: Block Insert
To add a comment prefix to multiple lines:
1. Move cursor to the first character of the first line
2. Press Ctrl+v to enter block visual mode
3. Use j to select multiple lines, then $ to extend to end of each line
4. Press I (capital i), type // or # for your comment prefix
5. Press Esc โ the prefix appears on all selected lines
Search and Replace Shortcuts
Search Commands
/pattern Search forward for pattern
?pattern Search backward for pattern
n Go to the next match
N Go to the previous match
* Search forward for the word under the cursor
# Search backward for the word under the cursor
g* Search forward for the word under cursor (partial match)
g# Search backward for the word under cursor (partial match)
gn Select the next match (for use with operators)
The gn command is especially useful: dgn deletes the next search match, and cgnfoo changes the next match to "foo". Combined with ., you can perform a search-and-replace interactively.
Interactive Search and Replace
:s/old/new/g Substitute on the current line (g flag = all occurrences)
:s/old/new/gc Substitute with confirmation on each match
:%s/old/new/g Substitute across the entire file
:%s/old/new/gc Substitute across file with confirmation
:'<,'>s/old/new/g Substitute within the last visual selection
Using Capture Groups
:%s/\(foo\)bar/\1baz/g Replace "foobar" with "foobaz" using capture group \1
:%s/\(\w\+\)\s\+\(\w\+\)/\2, \1/g Swap two words separated by whitespace
Window Management Shortcuts
Neovim's window system lets you split your editor into multiple viewports, each containing a different file or view of the same file:
Splitting Windows
:split {file} or :sp {file} Split horizontally, optionally opening {file}
:vsplit {file} or :vsp {file} Split vertically, optionally opening {file}
Ctrl+w s Split the current window horizontally
Ctrl+w v Split the current window vertically
Ctrl+w n Create a new horizontal split with a new empty buffer
Navigating Between Windows
Ctrl+w h Move to the window left
Ctrl+w j Move to the window below
Ctrl+w k Move to the window above
Ctrl+w l Move to the window right
Ctrl+w w Cycle to the next window
Ctrl+w W Cycle to the previous window
Ctrl+w p Go to the most recently accessed window
Ctrl+w t Go to the top-left window
Ctrl+w b Go to the bottom-right window
Resizing and Moving Windows
Ctrl+w = Equalize all window sizes
Ctrl+w _ Maximize current window vertically
Ctrl+w | Maximize current window horizontally
Ctrl+w + Increase height by one line
Ctrl+w - Decrease height by one line
Ctrl+w > Increase width by one column
Ctrl+w < Decrease width by one column
Ctrl+w H Move window to the far left (full height)
Ctrl+w J Move window to the far bottom (full width)
Ctrl+w K Move window to the far top (full width)
Ctrl+w L Move window to the far right (full height)
Ctrl+w r Rotate windows downward/rightward
Ctrl+w R Rotate windows upward/leftward
Ctrl+w x Exchange current window with next window
Closing Windows
Ctrl+w c Close the current window (or :close)
Ctrl+w q Quit the current window (or :quit)
Ctrl+w o Close all other windows, keep only the current one (:only)
:qall Quit all windows and exit Neovim
Tab Management Shortcuts
Tabs in Neovim are collections of windows. They're useful for organizing different workspaces:
:tabnew {file} Open a new tab, optionally with {file}
:tabclose Close the current tab
:tabonly Close all other tabs
gt Go to the next tab
gT Go to the previous tab
{count}gt Go to tab {count} (e.g., 3gt goes to tab 3)
:tabs List all open tabs with their buffer numbers
Rearranging Tabs
:tabmove {N} Move the current tab to position {N} (0-indexed)
:tabmove 0 Move current tab to the first position
:tabmove Move current tab to the last position (no argument)
Buffer Management Shortcuts
Buffers are the in-memory representation of files. You can have many buffers open but only see a few in your windows:
:ls or :buffers List all open buffers
:b {number} Switch to buffer by number
:b {name} Switch to buffer by name (partial match works)
:bn Go to the next buffer
:bp Go to the previous buffer
:bd Delete (close) the current buffer
:bd {number} Delete a specific buffer by number
:ba Open all buffers in split windows
Ctrl+^ Toggle between the current and alternate buffer
{count}Ctrl+^ Switch to buffer {count}
Undo, Redo, and History
u Undo the last change
Ctrl+r Redo the last undone change
U Undo all changes on the current line (since cursor last moved to it)
:undolist List the undo tree
g- Go to the previous (older) text state in the undo tree
g+ Go to the next (newer) text state in the undo tree
:earlier {count}s Go back {count} seconds in time
:earlier {count}m Go back {count} minutes in time
:later {count}s Go forward {count} seconds in time
Folding Shortcuts
Folding lets you collapse sections of code for better overview:
zf{motion} Create a fold from cursor to {motion} (e.g., zf5j folds 5 lines)
zf' Create a fold from cursor to mark a
zfa{ Fold a braced block
zo Open the fold under the cursor
zc Close the fold under the cursor
za Toggle the fold under the cursor
zR Open all folds in the file
zM Close all folds in the file
zr Open one level of folds across the file
zm Close one level of folds across the file
zd Delete the fold under the cursor
zE Delete all folds in the file
:set foldmethod=indent Set folding based on indentation
:set foldmethod=syntax Set folding based on syntax (requires language support)
Macros: Recording and Replaying
Macros let you record a sequence of commands and replay them โ perfect for repetitive tasks:
q{register} Start recording a macro into {register} (a-z)
q Stop recording (when pressed while recording)
{count}@{register} Execute the macro in {register} {count} times
@@ Repeat the last executed macro
:registers Display the contents of all registers
Practical Macro Example
To add a comma to the end of 50 lines:
1. Position cursor on the first line
2. Press qa to start recording into register a
3. Press A to append at end of line, type a comma, press Esc
4. Press j to move down one line
5. Press q to stop recording
6. Press 49@a to replay the macro 49 more times
Registers: The Clipboard System
Neovim has multiple registers for storing yanked/deleted text:
"{register}y{motion} Yank into a specific register
"{register}p Paste from a specific register
"" The unnamed register (default for yank/delete)
"0 The yank register (last yank, not overwritten by delete)
"1 through "9 Delete history registers (stack-based)
"+ The system clipboard register (requires +clipboard)
"* The primary selection register
"/ The search register (last search pattern)
": The command register (last Ex command)
"% The current file name register
". The last inserted text register
Clipboard Integration Example
"+yy Yank the current line to the system clipboard
"+p Paste from the system clipboard
"+d3w Delete three words and send them to the system clipboard
:let @+ = "Hello, world!" Set the clipboard contents programmatically
Customizing Keyboard Shortcuts
One of Neovim's greatest strengths is the ability to remap keys and create custom shortcuts. This is done in your configuration file (typically ~/.config/nvim/init.lua or init.vim):
Basic Key Mapping in Lua
-- Map a key to a command
vim.keymap.set('n', '<leader>w', ':w<CR>', { desc = 'Save file' })
-- Map with silent mode (no command echo)
vim.keymap.set('n', '<leader>q', ':q<CR>', { silent = true, desc = 'Quit' })
-- Map in multiple modes
vim.keymap.set({'n', 'v'}, '<C-d>', '<C-d>zz', { desc = 'Scroll down and center' })
Vimscript Mapping (for init.vim)
" Normal mode mapping
nnoremap <leader>w :w<CR>
" Insert mode mapping
inoremap jk <Esc>
" Visual mode mapping
vnoremap <leader>c " + y
The Leader Key
The leader key is a user-defined prefix for custom shortcuts. The default leader is backslash (\), but most users remap it to comma or space:
-- Set leader key to space (in init.lua)
vim.g.mapleader = ' '
vim.g.maplocalleader = ' '
-- Now <leader>w becomes Space+w
vim.keymap.set('n', '<leader>ff', ':Telescope find_files<CR>', { desc = 'Find files' })
vim.keymap.set('n', '<leader>fg', ':Telescope live_grep<CR>', { desc = 'Live grep' })
vim.keymap.set('n', '<leader>fb', ':Telescope buffers<CR>', { desc = 'Find buffers' })
Common Custom Mappings
-- Better window navigation (use Ctrl+hjkl instead of Ctrl+w hjkl)
vim.keymap.set('n', '<C-h>', '<C-w>h', { desc = 'Go to left window' })
vim.keymap.set('n', '<C-j>', '<C-w>j', { desc = 'Go to window below' })
vim.keymap.set('n', '<C-k>', '<C-w>k', { desc = 'Go to window above' })
vim.keymap.set('n', '<C-l>', '<C-w>l', { desc = 'Go to right window' })
-- Move lines up/down in visual and normal mode
vim.keymap.set('v', 'J', ":m '>+1<CR>gv=gv", { desc = 'Move selection down' })
vim.keymap.set('v', 'K', ":m '<-2<CR>gv=gv", { desc = 'Move selection up' })
-- Quick escape from insert mode
vim.keymap.set('i', 'jk', '<Esc>', { desc = 'Exit insert mode' })
vim.keymap.set('i', 'jj', '<Esc>', { desc = 'Exit insert mode (alternative)' })
Best Practices for Learning and Using Shortcuts
1. Learn Gradually, Not All at Once
Start with the essential movement keys (hjkl, w, b, ^, $) and basic operators (d, c, y, p). Add one new concept per week โ text objects one week, window management the next, macros after that. The goal is muscle memory, not memorization.
2. Stay in Normal Mode
The biggest efficiency gain comes from minimizing time in Insert mode. Develop the habit of pressing Esc immediately after finishing an insertion. Navigate in Normal mode, edit surgically, and return to Insert only when typing new text.
3. Make Every Edit Repeatable
When performing a change, ask yourself: "Can I use . to repeat this elsewhere?" Prefer text-object-based edits (ciw, ca") over manual selections because they are inherently repeatable with the dot command.
4. Use Relative Line Numbers
Enable relative line numbers to make vertical jumps effortless:
-- In init.lua
vim.opt.relativenumber = true
vim.opt.number = true -- Shows absolute number on current line
With relative numbers, 12j jumps exactly 12 lines down. This is far more intuitive than counting lines manually.
5. Map Common Annoyances Away
Identify the operations you perform dozens of times daily and create shortcuts for them. Common candidates include toggling between header and source files, running project build commands, or opening frequently used files.
6. Use Which-Key for Discovery
Install a plugin like which-key.nvim to display available keymaps when you pause after pressing a prefix key like <leader> or <C-w>. This turns your custom mappings into a discoverable menu.
7. Never Force a Bad Habit
If you find yourself constantly fighting a particular shortcut, remap it. Neovim is meant to adapt to you, not the other way around. If jk feels better than Esc for exiting Insert mode, use it. Comfort leads to consistency, and consistency leads to speed.
8. Practice with Purpose
Use vimtutor (run :Tutor in Neovim) for guided practice. Spend 10 minutes daily drilling a specific skill โ like jumping with f/t or using macros โ on real code rather than abstract exercises.
Cheat Sheet: Quick Reference Tables
Movement Quick Reference
โโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Shortcut โ Action โ
โโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ h, j, k, l โ Left, down, up, right โ
โ w, b, e, ge โ Word forward/back/end/back-end โ
โ 0, ^, $ โ Line start/first-char/end โ
โ gg, G โ File start/end โ
โ Ctrl+f, Ctrl+b โ Full screen forward/back โ
โ Ctrl+d, Ctrl+u โ Half screen forward/back โ
โ f{char}/F{char} โ Find char forward/back on line โ
โ t{char}/T{char} โ Until char forward/back on line โ
โ %, {, } โ Match bracket, paragraph prev/next โ
โโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Operator Quick Reference
โโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Operator โ Action โ
โโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ d โ Delete โ
โ c โ Change (delete + insert) โ
โ y โ Yank (copy) โ
โ p / P โ Paste after/before โ
โ x / X โ Delete char under/before โ
โ r โ Replace single character โ
โ s / S โ Substitute char/line โ
โ . โ Repeat last change โ
โ > / < โ Indent/dedent โ
โ = โ Auto-format/indent โ
โ gU / gu โ Uppercase/lowercase โ
โ g~ โ Toggle case โ
โโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Text Object Quick Reference
โโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Object โ Selects โ
โโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ iw / aw โ Inner/a word โ
โ iW / aW โ Inner/a WORD โ
โ i" / a" โ Inside/around double quotes โ
โ i' / a' โ Inside/around single quotes โ
โ i( / a( โ Inside/around parentheses โ
โ i[ / a[ โ Inside/around brackets โ
โ i{ / a{ โ Inside/around braces โ
โ it / at โ Inside/around XML/HTML tags โ
โ ip / ap โ Inner/a paragraph โ
โ is / as โ Inner/a sentence โ
โโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Conclusion
Neovim's keyboard shortcut system is not just a set of key combinations to memorize โ it's a composable language for expressing editing intent. By internalizing the core movements, operators, and text objects, you gain the ability to communicate with your editor at the speed of thought. The journey from novice to proficient Neovim user is one of gradual accumulation: start with the home-row movement keys and basic delete operations, layer in text objects for surgical precision, then expand into window management and macros for project-level efficiency. Customize aggressively โ remap keys to suit your workflow, define leader-key shortcuts