Commands, Motions and Text Objects
cit<td>Value</td><ESC>llci</tr<ESC>^ci<tr
- Before:
<li>Value</li>
- After:
<tr><td>Value</td></tr>
<subject> <verb> <object>
I love Vim
<command> <motion>
dw
(delete word)
Move your cursor
h
,j
,k
,l
just like the arrow keys^
beginning of line$
end of line (think regex)
w
move forward one wordb
move to beginning of worde
move to end of word
Slow, can be a crutch
d
Delete (also cut)c
Changey
Yank (copy)=
Auto-indent<
/>
Indent left/right
dd
Delete the current linecc
Change current lineyy
Yank current line
d$
Delete till the end of the linec^
Change till the beginning of the linedj
Delete the current line and the one below
t<char>
till character (excluding character)f<char>
find character
dtl
Delete till thel
cfe
Change up to (and including)e
<command> <modifier> <motion>
d3j
Delete the current line and 3 lines below itd4t)
Delete till the fourth parenthesis
iw
/aw
inner/around wordis
/as
inner/around sentenceip
/ap
inner/around paragraphit
/at
inner/around tag
<command> <modifier> <text object>
-
dap
delete around paragraph: delete paragraph including surrounding whitespace -
d2as
delete around two sentences
ci(
change inner parenthesis
ci"
change inner double quotes
cit<td>Value</td><ESC>llci</tr<ESC>^ci<tr
- Before:
<li>Value</li>
- After:
<tr><td>Value</td></tr>
cit<td>Value</td><ESC>
Change contents of tag to <td>Value</td>
, return to normal mode
- Before:
<li>Value</li>
- After:
<li><td>Value</td></li>
llci</tr<ESC>
Move right two characters, change the contents of the angle brackets to /tr
,
return to normal mode
- Before:
<li><td>Value</td></li>
- After:
<li><td>Value</td></tr>
^ci<tr
Move to the beginning of the line, change to contents of the angle brackets to
tr
- Before:
<li><td>Value</td></tr>
- After:
<tr><td>Value</td></tr>
Adding more verbs and nouns
tpope/vime-commentary
comments out the given text object
nelstrom/vim-textobj-rubyblock
ruby blocksmichaeljsmith/vim-indent-object
indentation level
- Github: @JoelQ
- Twitter: @joelquen
- Slides: https://github.com/JoelQ/vim-grammar
- Cheat sheet: https://github.com/JoelQ/vim-grammar/blob/master/cheat_sheet.md