Modes, navigation, editing, search, macros & configuration
Editor# Normal mode (default) — navigation & commands
# Insert mode — typing text
# Visual mode — selecting text
# Command mode — ex commands (:)
i # insert before cursor
I # insert at line start
a # insert after cursor
A # insert at line end
o # new line below
O # new line above
Esc # back to normal mode# Delete
x # delete char X # delete before
dd # delete line D # delete to end
dw # delete word d$ # delete to end
d0 # delete to start
# Change (delete + insert mode)
cc # change line cw # change word
C # change to end ci" # change inside ""
# Copy & Paste
yy # yank (copy) line
yw # yank word
p # paste after P # paste before
# Undo & Redo
u # undo Ctrl+r # redo
# Other
. # repeat last command
~ # toggle case
J # join lines
>> # indent << # unindent/pattern # search forward
?pattern # search backward
n # next match
N # previous match
* # search word under cursor
# Replace
:s/old/new/ # first in line
:s/old/new/g # all in line
:%s/old/new/g # all in file
:%s/old/new/gc # all with confirm
:5,10s/old/new/g # lines 5-10
# Clear search highlight
:nohv # character selection
V # line selection
Ctrl+v # block selection
# In visual mode:
d # delete selected
y # yank selected
> # indent
< # unindent
~ # toggle case
: # command on selection
# Select inner/around
vi" # select inside quotes
va( # select around parens
vit # select inside HTML tag
viw # select inner word
vip # select inner paragraph:w # save
:q # quit
:wq or :x # save & quit
:q! # quit without saving
:e file.txt # open file
:bn :bp # next/prev buffer
:ls # list buffers
:sp file.txt # horizontal split
:vsp file.txt # vertical split
Ctrl+w h/j/k/l # navigate splits
:tabnew f.txt # new tab
gt gT # next/prev tab# Record macro
qa # start recording into register 'a'
<do commands>
q # stop recording
# Play macro
@a # play register 'a'
@@ # repeat last macro
10@a # play 10 times
# Registers
"ay # yank into register 'a'
"ap # paste from register 'a'
:reg # show all registersset number " line numbers
set relativenumber " relative numbers
set tabstop=4 " tab width
set shiftwidth=4
set expandtab " spaces instead of tabs
set autoindent
set hlsearch incsearch " search highlight
set ignorecase smartcase
set mouse=a " enable mouse
set clipboard=unnamedplus " system clipboard
syntax on
filetype plugin indent on