Vim Muscle Memory Cheat Sheet

A Software › Vim cheat sheet in English by fraz

Some muscle memory shortcuts for vim

7,128 views 2,185 downloads 14 Mar 2019 History
3.7 avg · 0 ratings

Normal to Insert Mode

ea ou gea
end append
cgn
change current search result
3>>
Indent 3 lines

Motion

50%
Go to {count}% of the file

Command Mode

:n
Go to line n
:{rang­e}>>
Indent range
:g/foo/#
Print lines containing foo
:tj /foo
Jump to tag containing foo

Search Motions

d/ab
Delete till ab (Exclude pattern)
d/ab then dn
Delete till ab and then delete till next
d/ab/e
Delete till ab (Include pattern)
d/ab/b+1
Include first char in pattern
dv/ab
Delete till ab (Inclusive - 1)
dV/ab
Delete till line ab (Linewise)
d/ab/0
Delete till line ab (Linewise)

Text Objects

gn
Search next pattern
ib, ab
For ()
iB, aB
For {}
ap
cap : Change arround paragraph

Operators

d
Delete
c
Change
y
Yank
=
Equalize
>
Indent
gu
InnerCase
gq /gw
Format /(Keep Cursor)
gc
Comment
g?
Rotate 13

Insert Quickly

5o<­Esc>
Insert 5 lines
5i<­Esc>
Insert 5 spaces

Copy / Paste / Delete

ddp
Exchange with line below
ddkp
Exchange with line above
xp
Exchange characters
yyp
Copy paste a line
yw
Yank word
pkJ
Paste up join
dw
Delete word
hdeep
Swap two words
vep
Visual end paste
dvip
Many blank lines to 1 blank line
:12y
Yank line 12
7dd
d6j - delete 7 lines
:%d
Delete buffer content
:m$
Move current line at the end
cw<­c-r­>0
Replace with yanked text in insert mode
:10t.
Copy line 10 below current line

Search

:ilist /foo
Search for /foo
:dlist /foo
Search definition for /foo
\zs and \ze
Set Start/End of the match

Visual Mode

viwp
Select and paste word
vep
Select till end and paste
vG
Visual Select to the end
v$%
Select a function block
{count­}g<­C-a>
Increment by count ( C-X for decrement)
<C-­v>6$
Select quickly 6 end of lines
vapapap
Select more and more paragraphs
vfa
Select to char a in a line

Repeat commands

. (dot)
Repeat last insert
n or N
Repeat last search
&
Repeat last substi­tution
g&
Repeat last substi­tution on entire file
; or ,
Repeat last search with f or t
:normal .
Repeat using normal command
@:
Repeat last ex command

Miscel­laneous

ZZ
Save and Quit
:read! cmd
Read cmd line results

Marks and Jumps

gi
Last edit and go to insert mode
g; and g,
Last changes
``
Back to previous context
'{ and '}
Start / End of current paragraph
'[ and ']
Start/End of last change or yank
'< and '>
Start/End of last visual selection

Tips

22<­C-X>
Decrement quickly by 22

Comments

No comments yet.

Cheatography n. The art of mapping complex subjects into clear, instantly navigable reference guides.