Show Menu
Cheatography

KND Vim Cheat Sheet Keyboard Shortcuts by

Working with Files

:e [filename]
Open file
:w [filename]
Save changes to file
:x
:wq

Manage Multiple Files

[Ctrl+w] s
Split current window horizo­ntally
[Ctrl+w] v
Split current window vertically
:sp {file}
Load file into another horizontal window
:vsp {file}
Load file into another vertical window
[Ctrl+w] h / j / k / l
Navigate between windows
[Ctrl+w] c
Close active window
[Ctrl+w] o
Close other windows except active one
[Ctrl+w] =
Equalize width & height of all windows
:tabe {filename}
Load file in opening tab
:tabc
Close active tab
:tabo
Close other tabs
{N}gt
Switch to tab page number {N}
:tabmove [N]
Move current tab to Nth position
:find {filename}
Opening file with relative path
:e.
Open file explorer for current working dir:
zz
Center screen at cursor
 

Navigate inside file

e
End of next word
E
w
Begin of next word
W
b
Begin of previous word
B
0
Begin of line
^
$
End of line
H
Begin screen line
M
Middle screen line
L
End screen line

Inside Visual Mode

V
Select entire line
bvw
Select a word under cursor
byw
Yank a word
Y
Yank entire line
p
Paste after cursor
P
Paste before cursor
V[#lines]G
Select a code block

Tips

Use dot formula

Search & Replace

/{pattern}
n / N
?{pattern}
n / N
:noh
Removes highlights
:%s/{o­ld}­/{n­ew}/g
Replace {old} by {new} globally
/f{char}
; / ,
/F{char}
; / ,

NERDTree

o
Open file
go
Open file (cursor in NERDTree)
t
Open file in new tab
O
Open recurs­ively directory
X
Close recurs­ively directory
x
Close current nodes' parent
s
Open selected file in a new vsplit
gs
Same as s (cursor in NERDTree)
C
Change the tree root to the selected dir
R
Recurs­ively refresh the current root
 

Modifying file

I
Insert at begin word of line
A
Insert at end of line
o
Insert one line below
O
Insert one line above
C
Remove rest line, insert mode
s
Remove 1 char, insert mode
S
Remove 1 line, insert mode
dd
Remove a line
D
Remove rest of line
x
Remove 1 char after
X
Remove 1 char before
Ctrl+r
Redo
ciw
Remove and insert under cursor word
c[#]aw
Remove next # number of words, insert mode
d[#]aw
Remove # number of words
[#]Ctrl+a
Add # to the next number occurence
[#]Ctrl+x
Subtract # from the next number occurence
~
Change case of selected text
g~iw
Change case of word
ci"
Delete inside double quotes (insert mode)

Search text in files

:vimgrep /{patt­ern­}/[­g][j] {file/dir}
"­g" including multiple matches on same line
 
"­j" turning off auto-goto first match feature
 
"­**" means all sub-di­rec­tories
:cw
Show list of searched files & locations
 

Comments

Oh yeah!!!!!!

Add a Comment

Your Comment

Please enter your name.

    Please enter your email address

      Please enter your Comment.