Neovim Cheatsheet: The Complete Guide to Mastering Neovim Commands
Learn the essential Neovim commands and shortcuts with this categorized cheatsheet designed for maximum productivity in coding and text editing.
General Commands
File Management
:e filename " Open a file
:w " Save the current file
:q " Quit Neovim
:wq " Save and quit
:x " Shortcut for :wq
:qa " Quit all files
:wa " Save all open filesBuffers
:bnext " Go to the next buffer
:bprev " Go to the previous buffer
:bd " Close the current buffer
:ls " List all buffers
:buffer N " Switch to buffer NWindows (Splits)
:split " Horizontal split
:vsplit " Vertical split
Ctrl-w w " Switch between windows
Ctrl-w h/j/k/l " Navigate windows
Ctrl-w q " Close the current window
Ctrl-w = " Equalize window sizesEditing
Modes
i " Insert mode
a " Append after cursor
I " Insert at the beginning of the line
A " Append at the end of the line
Esc " Return to normal modeText Manipulation
dd " Delete a line
yy " Copy a line
p " Paste below the current line
P " Paste above the current line
x " Delete a character
u " Undo the last change
Ctrl-r " Redo the last undoIndentation
>> " Indent the current line
<< " Un-indent the current line
= " Auto-indent a line or selectionNavigation
By Character/Word
h " Move left
l " Move right
w " Jump to the start of the next word
e " Jump to the end of the current/next word
b " Jump to the beginning of the previous wordBy Line
0 " Jump to the beginning of the line
^ " Jump to the first non-whitespace character
$ " Jump to the end of the lineBy Paragraph
{ " Jump to the beginning of the previous paragraph
} " Jump to the beginning of the next paragraphBy Screen
Ctrl-d " Scroll down half a screen
Ctrl-u " Scroll up half a screen
Ctrl-f " Scroll down a full screen
Ctrl-b " Scroll up a full screenBy Search
/pattern " Search for 'pattern'
?pattern " Search backward for 'pattern'
n " Repeat the last search forward
N " Repeat the last search backwardVisual Mode
Mode
v " Enter visual mode
V " Enter line visual mode
Ctrl-v " Enter block visual mode
o " Switch to the other end of the selectionCommand Mode
Searching and Replacing
:s/old/new/ " Replace the first occurrence of 'old' with 'new' in the current line
:s/old/new/g " Replace all occurrences in the current line
:%s/old/new/g " Replace all occurrences in the entire file
:%s/old/new/gc " Replace with confirmationExiting
:w " Save the file
:q " Quit
:wq " Save and quit
:q! " Quit without savingPlugins
Plugin Manager (Packer Example)
:PackerInstall " Install plugins
:PackerUpdate " Update plugins
:PackerClean " Remove unused plugins
:PackerSync " Install, update, and clean pluginsNvim-tree (File Explorer)
<leader>e " Toggle the file explorerKey Bindings
Customization Examples
nnoremap key command " Map a key in normal mode
inoremap key command " Map a key in insert mode
vnoremap key command " Map a key in visual modeConfiguration
init.vim (Vimscript)
set number " Show line numbers
syntax on " Enable syntax highlighting
set expandtab " Use spaces instead of tabs
set tabstop=4 " Set tab width to 4 spaces
set shiftwidth=4 " Set indentation width to 4 spacesinit.lua (Lua)
vim.o.number = true -- Show line numbers
vim.cmd('syntax on') -- Enable syntax highlighting
vim.o.expandtab = true -- Use spaces instead of tabs
vim.o.tabstop = 4 -- Set tab width to 4 spaces
vim.o.shiftwidth = 4 -- Set indentation width to 4 spaces