My Evil Cheat Sheet
2017-11-13
Evil-mode is an Emacs layer that allows editing using Vim. Therefore this is a also a cheat sheet for Vim itself.
Cheat Sheet for Evil mode
Navigating
h
j
k
l
w
: move forward by one wordb
: move backward by one word, the opposite ofw
.e
: move forward to the end of a wordgg
G
:<NUM>
: Go to line number0
: =Home
$
: =End
C-u
: move up half screenC-d
: move down half screenC-f
: move down a whole pageC-b
: move up a whole page
Enter Insert State
i
a
I
A
$a
s
: delete a char and insert.S
: (substitute) delete the whole line and start from the begining, =0C
.
Editing
y
: yank/copyyy
: yank the current linep
: pasteP
: paste before cursord
: delete/cutD
: delete to the end of the linedt.
: delete to the period. Similar asdf.
, which will delete.
as well.u
: undoC-R
: redox
: delete char at current position.X
: delete char before current position.
Replace
r
R
:s/old_word/new_word/gc
:g
means “global”, parameterc
means “confirmation”cw
: change word
Search
/
: search forward.?
: search backward.*
or#
: find the previous/next occurance of current word in Evil-mode.f<char>
: find the next<char>
.f3c
can find the 3rd occurence ofc
.F<char>
: the opposite of the above.t<
: find forward and land right before the char.
Miscellaneous Command
:!<command>
.
: repeat the previous command. Be careful of what is the “previous command”.
Formatting
~
: toggle upper and lower case of the current char.gq ap
: format the whole paragraph.
Visual Mode
v
: select charV
: select lineC-v
: select paragraph
Advanced
daw
: delete around word.diw
: delete inside word.dis
das
cis
: delete and insert at current sentencedip
: paragraphdap
di'
/da'
: single quotedi"
/da"
: double quote[ai]["`([{"]
: all kinds of scopedit
/dat
: inside / around tag- replace
d
above byv
: visualize the designated scope. vipyjjp
: copy this paragraph and paste it below. (just some combination)qa
, insert a:
at the beginning of the line, go to next line,q
: finish recording a macro, next,100@a
, now, next 100 lines has a:
in front of them.- Some possible macros:
- Search within the line for “widget”;
- Go to the end of line and add a
.
; - Delete any whitespaces at the end of the line.
cs"'
: change the surrounding double quotes to single ones.cs'<p>
: change single quotes to<p>
.ds'
: delete the surrounding single quotes.ysiw'
: wrap current word with'
.:%y+
: copy all, =Ctrl + A
in casual text editor.gg"+yG
: similar function.ggvG
: similar function, text not copied. Pressy
to do so.