Links
Most of commands accept number before (eg: 3k
moves down 3 times)
keys
[leader]
is default to\
(usemapleader
or see:help leader
)
plugins
- nerdcommenter :
\cc
,\cu
nerdtree
s will open the file currently under the cursor in a new vertically split window. Use t to open in a new tab.
modes
i
- insert modev
- visual, used for text selectionCtrl+v
- Visual block mode (used to select text blocks)
normal (default) mode
I
- enter insert mode at the beginning of the lineA
- insert at the end of the linecw
- Change wordcgn
- Change the next search match (useful to change searched text)u
- ↩️ UndoCtrl+r
Redo.
- 🔁 Repeat last commandNdd
- ❌ DeleteN
linesx
- ❌ Delete charo
- ↵ Add a new lineA
- Insert at the line end
:open X
- Open file:ter[minal]
- Open terminalctrl+w v
- Split screen horizontallyctrl+w s
- Split verticallyctrl+w l/h/j/k
- Switch to right/left/up/down sidectrl+w L/H/J/K
- Switch to panel to right/left/up/downctrl+w </>
- Resize panel widthctrl+w +/-
- Resize panel height:tabl/r
- Switch between tabs
visual mode commands
v
- Go to visual modey
- Copy textd
- delete selectionx
- cut selection / delete characterp
,P
- paste selection before/after custor (ori
in Command mode)dw
- delete wordV
- select linecw
- change wordC
- change whole lineD
- Delete rest of line from cursor
navigate
j
,k
- ⬆️ ⬇️h
,l
- ⬅️ ➡️0
,$
- Go to Start/End of the linew
,W
(ore
,E
,B
) - Move by wordb
- Back to wordgg
- Go to endG
- Go to endG;
- Go to previous position
search and replace
/text
- 🔍 search fortext
?text
- Search topn
,N
- Go to next/previous search result:%s/str/rep
- Replacestr
withrep
10G
- Go to line10
bookmarks
mx
- Create a mark with namex
(mark this position)'x
- Jump to markx
view & layout
:split FILE_NAME
- Split vertically and open file
macros
q1
- Start macros with number1
(basically record and replay commands)q
- Stop macro record@1
- Call1
macro10@1
Run1
macro 10 times
a few ways to get out of Vim
ZZ
,:q!
,:!kill -9 $PPID
special commands
Lines
:10,33>
- Add intentation to lines between10-33
:/Foo/+1m-2
- Move line down nearFoo
line:/Foo/m$
- MoveFoo
line to the end of document
Misc
:ab x TEXT
- Create abbreviationx
.- Type
x
in insert mode to insert specified abbreviation. - Enter
ctrl+v
to prevent expansion.
- Type
:! command
- Run shell command:w !sudo tee %
- If you have write permission error
Visual block commands
:'<,'>
- Run command for all lines (from first to last)norm
- enter normal mode:'<,'> norm I"
- Insert doublequote at the beginning of all selected lines:'<,'> norm A"
- the same, but at the EOL.