Vim motions

From wikinotes

vim commands are usually composable with text-objects.
text objects let you refer to groups of tokens in your file with a letter or two.

For example

ci}  " change all text within {}s (from anywhere within {}s)
daw  " delete a word (from anywhere in word)

Documentation

:h motion https://vimhelp.org/motion.txt.html#motion.txt

Basics

Operators

There are many more listed in manual, but most common:

c    " change
d    " delete
y    " yank
~    " swap case
>, < " indent/dedent

Motion Style

Vertical

dj      " (default) operate on lines
dvj     " (v) operate by cursor position
d<c-v>j " (c-v) operate as if visual-selection made

Horizontal

dh, dl  " operate left/right
d0, d$  " operate from cursor to start/end of line
d^      " operate from cursor to first non-blank character of line
f, F    " operate from cursor to next/prev character
t, T    " operate from cursor to just before/after next/prev character
;       " repeat last f,F,t,T
,       " repeat last f,F,t,T in opposite direction

Multiline

]m      " ']' accepts a text-object to jump to (ex. method, sentence, ...)
%       " jump to end of if, bracket, etc

Text Objects

Word context/selector

" test object selection in :help
daw  " (a) delete a word+whitespace (from anywhere in word)
diw  " (i) delete inner word, leaving it's whitespace (from anywhere in word)

Object types

w " word
s " sentence  (ends in .,!,?)
p " paragraph (blank line delimited)
t " xml-tag   (between <></>s)
m " method    (language dependent)
} " block     (between {}s)
] "           (between []s)
) "           (between ()s)
" "           (between ""s on same line)
' "           (between ''s on same line)
` "           (between ``s on same line)