Neovim Cheat Sheet

Basic Movement
CommandDescriptionReal-World Example
h / lMove left/right by one character
    Input:  h
    Effect: Cursor moves one character to the left
            
j / kMove down/up by one line
    Input:  j
    Effect: Cursor moves one line down
            
w / bJump forward/backward to the start of the next/previous word
    Input:  w
    Effect: Cursor jumps to the next word
            
eJump to the end of the current/next word
    Input:  e
    Effect: Cursor jumps to the end of the current/next word
            
0Move 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 / ?patternSearch forward/backward for a pattern
    Input:  /function
    Effect: Cursor jumps to the next occurrence of "function"
            
n / NRepeat last search forward/backward
    Input:  n
    Effect: Jumps to next match of last search
            
Inserting & Editing
CommandDescriptionReal-World Example
iInsert before the cursor
    Input:  iHello
    Effect: Inserts "Hello" before cursor position
            
IInsert at the beginning of the line
    Input:  IHello
    Effect: Inserts "Hello" at the start of the current line
            
aInsert after the cursor
    Input:  aWorld
    Effect: Inserts "World" just after the current character
            
AInsert at the end of the line
    Input:  A!
    Effect: Appends "!" at the end of the current line
            
oOpen a new line below and insert
    Input:  oNew line
    Effect: Creates a new line below and starts inserting "New line"
            
OOpen a new line above and insert
    Input:  OHeader
    Effect: Adds "Header" on a new line above the current one
            
xDelete character under the cursor
    Input:  x
    Effect: Deletes the current character
            
ddDelete the current line
    Input:  dd
    Effect: Removes the entire line where the cursor is
            
dwDelete 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
            
DSame as d$
    Input:  D
    Effect: Deletes everything to the right of the cursor
            
cwChange word (delete and enter insert mode)
    Input:  cwHello
    Effect: Replaces the current word with "Hello"
            
ccChange the whole line
    Input:  ccHello World
    Effect: Replaces the entire line with "Hello World"
            
CChange from cursor to end of line
    Input:  CHi!
    Effect: Changes from current position to end of line to "Hi!"
            
sSubstitute character under cursor
    Input:  sA
    Effect: Replaces current character with "A"
            
rReplace a single character
    Input:  rX
    Effect: Replaces current character with "X"
            
REnter replace mode until <Esc>
    Input:  RHELLO
    Effect: Overwrites characters with "HELLO"
            
Copy & Paste
CommandDescriptionReal-World Example
yyYank (copy) the current line
    Input:  yy
    Effect: Copies the entire line into default register
            
ywYank 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
            
YYank the entire line (same as yy)
    Input:  Y
    Effect: Copies the whole line
            
pPaste after the cursor or below the line
    Input:  p
    Effect: Pastes yanked content after cursor or below the line
            
PPaste before the cursor or above the line
    Input:  P
    Effect: Pastes yanked content before cursor or above the line
            
"aYYank current line into register “a”
    Input:  "aY
    Effect: Saves the current line into register a
            
"apPaste from register “a”
    Input:  "ap
    Effect: Pastes content stored in register a
            
Undo & Redo
CommandDescriptionReal-World Example
uUndo 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 u
            
Visual Mode
CommandDescriptionReal-World Example
vEnter visual mode (character-wise selection)
    Input:  v (then move with arrows or hjkl)
    Effect: Highlights characters one by one
            
VEnter 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
            
yYank the selected text
    Input:  v (select) → y
    Effect: Copies the selected area
            
dDelete the selected text
    Input:  V (select lines) → d
    Effect: Deletes selected lines
            
pPaste 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
CommandDescriptionReal-World Example
/patternSearch forward for a pattern
    Input:  /error
    Effect: Highlights and jumps to the next occurrence of "error"
            
?patternSearch backward for a pattern
    Input:  ?function
    Effect: Searches up the file for "function"
            
nRepeat the last search in the same direction
    Input:  n
    Effect: Jumps to the next match of the last search
            
NRepeat the last search in the opposite direction
    Input:  N
    Effect: Jumps to the previous match of the last search
            
:%s/old/new/gReplace 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/gcReplace “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
            
CommandDescriptionReal-World Example
:e filenameEdit/open a file
    Input:  :e notes.txt
    Effect: Opens "notes.txt" in the current window
            
:Ex / :ExploreOpen file explorer
    Input:  :Ex
    Effect: Opens a split file explorer in the current directory
            
:lsList all open buffers
    Input:  :ls
    Effect: Shows all currently open files (buffers)
            
:bnextGo to next buffer
    Input:  :bnext
    Effect: Switches to the next file in the buffer list
            
:bprevGo to previous buffer
    Input:  :bprev
    Effect: Switches to the previous file in the buffer list
            
:bdDelete/close a buffer
    Input:  :bd
    Effect: Closes the current buffer
            
<C-w>vSplit window vertically
    Input:  Ctrl + w, then v
    Effect: Opens a vertical split
            
<C-w>sSplit window horizontally
    Input:  Ctrl + w, then s
    Effect: Opens a horizontal split
            
<C-w>h/j/k/lMove between windows
    Input:  Ctrl + w, then l
    Effect: Moves to the window on the right
            
:tabnewOpen a new tab
    Input:  :tabnew
    Effect: Opens a new empty tab
            
gtGo to next tab
    Input:  gt
    Effect: Switches to the next tab
            
gTGo to previous tab
    Input:  gT
    Effect: Switches to the previous tab
            
LSP & Completion
CommandDescriptionReal-World Example
gdGo to definition of symbol
    Input:  gd
    Effect: Jumps to the function or variable definition under the cursor
            
KShow hover documentation
    Input:  K
    Effect: Shows documentation for the symbol under the cursor
            
<leader>rnRename 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
CommandDescriptionReal-World Example
:wSave the current file
    Input:  :w
    Effect: Saves the current file
            
:qQuit Neovim
    Input:  :q
    Effect: Exits Neovim (only works if no changes are unsaved)
            
:wqSave and quit Neovim
    Input:  :wq
    Effect: Saves the file and exits Neovim
            
:xSave 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
            
:!commandExecute an external command
    Input:  :!ls
    Effect: Runs the "ls" command in the terminal and displays the output inside Neovim
            
:nohClear search highlighting
    Input:  :noh
    Effect: Clears any active search highlighting
            
:set pasteEnable paste mode (useful when pasting text)
    Input:  :set paste
    Effect: Temporarily disables automatic indentation and formatting, ideal for pasting text
            
File & Buffer Management
CommandDescriptionReal-World Example
:e filenameOpen a file for editing
    Input:  :e example.txt
    Effect: Opens "example.txt" in the current window for editing
            
:wSave the current file
    Input:  :w
    Effect: Saves the changes made to the current file
            
:qQuit Neovim
    Input:  :q
    Effect: Exits Neovim (only works if no changes are unsaved)
            
:lsList all open buffers
    Input:  :ls
    Effect: Displays a list of all open buffers in Neovim
            
:bnextSwitch to the next buffer
    Input:  :bnext
    Effect: Switches to the next buffer in the buffer list
            
:bprevSwitch to the previous buffer
    Input:  :bprev
    Effect: Switches to the previous buffer in the buffer list
            
:bdClose 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
            
:spSplit the window horizontally and load a file
    Input:  :sp example.txt
    Effect: Opens "example.txt" in a horizontal split
            
:vspSplit the window vertically and load a file
    Input:  :vsp example.txt
    Effect: Opens "example.txt" in a vertical split
            
Window Management
CommandDescriptionReal-World Example
<C-w>vSplit the window vertically
    Input:  <C-w>v
    Effect: Splits the current window into two vertical panes
            
<C-w>sSplit the window horizontally
    Input:  <C-w>s
    Effect: Splits the current window into two horizontal panes
            
<C-w>h/j/k/lNavigate 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>qClose the current window
    Input:  <C-w>q
    Effect: Closes the current window, leaving the other panes open
            
<C-w>wSwitch to the next window
    Input:  <C-w>w
    Effect: Cycles to the next window in the current layout
            
<C-w>HMove 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>JMove the current window to the bottom
    Input:  <C-w>J
    Effect: Moves the current window to the bottom of the layout
            
<C-w>KMove the current window to the top
    Input:  <C-w>K
    Effect: Moves the current window to the top of the layout
            
<C-w>LMove the current window to the far right
    Input:  <C-w>L
    Effect: Moves the current window to the far right of the layout
            
Tabs
CommandDescriptionReal-World Example
:tabnewOpen a new tab page
Input:  :tabnew
Effect: Opens a new tab page (creates a new workspace)
        
gtSwitch to the next tab
Input:  gt
Effect: Switches to the next tab in the tab list
        
gTSwitch to the previous tab
Input:  gT
Effect: Switches to the previous tab in the tab list
        
:tabnGo to the next tab
Input:  :tabn
Effect: Switches to the next tab
        
:tabpGo to the previous tab
Input:  :tabp
Effect: Switches to the previous tab
        
:tabnew filenameOpen a file in a new tab
Input:  :tabnew example.txt
Effect: Opens "example.txt" in a new tab
        
:tabcloseClose the current tab
Input:  :tabclose
Effect: Closes the current tab (and all its windows)
        
Customization
CommandDescriptionReal-World Example
:set numberEnable line numbering
Input:  :set number
Effect: Displays line numbers in the left margin
        
:set relativenumberEnable relative line numbering
Input:  :set relativenumber
Effect: Displays line numbers relative to the cursor position
        
:set hlsearchHighlight search results
Input:  :set hlsearch
Effect: Highlights all matches for the search pattern
        
:set incsearchEnable incremental search
Input:  :set incsearch
Effect: Shows search results as you type
        
:set ignorecaseEnable case-insensitive search
Input:  :set ignorecase
Effect: Makes search patterns case-insensitive
        
:set smartcaseEnable smart case search
Input:  :set smartcase
Effect: Enables case-sensitive search only when uppercase characters are used in the pattern
        
:set tabstop=4Set tab width to 4 spaces
Input:  :set tabstop=4
Effect: Sets the tab width to 4 spaces
        
:set shiftwidth=4Set the number of spaces to use for indentation
Input:  :set shiftwidth=4
Effect: Sets the indentation width to 4 spaces
        
:set expandtabConvert tabs to spaces
Input:  :set expandtab
Effect: Converts tabs to spaces when pressing the Tab key
        
Plugin Management
CommandDescriptionReal-World Example
:PlugInstallInstall plugins with vim-plug
Input:  :PlugInstall
Effect: Installs all plugins listed in the vim-plug plugin manager configuration
        
:PlugUpdateUpdate installed plugins
Input:  :PlugUpdate
Effect: Updates all installed plugins to the latest version
        
:PlugCleanRemove unused plugins
Input:  :PlugClean
Effect: Removes plugins that are no longer listed in the vim-plug configuration
        
:PluginInstallInstall plugins with Pathogen
Input:  :PluginInstall
Effect: Installs plugins defined in the Pathogen configuration
        
:PluginUpdateUpdate plugins with Pathogen
Input:  :PluginUpdate
Effect: Updates all plugins installed via Pathogen
        
:PackerSyncSync and update plugins with Packer
Input:  :PackerSync
Effect: Installs, updates, and removes plugins defined in the Packer configuration
        

Leave a Comment

Your email address will not be published. Required fields are marked *

Shopping Cart