💾 Archived View for gemini.susa.net › Vim › vim_motions.gmi captured on 2022-06-03 at 23:24:33. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2021-11-30)

-=-=-=-=-=-=-

Motions in Vim

Can be combined with 'operators' such as 'd', and counts.

Left/Right (characterwise)

h, l     Left, right
^, g_    First, last non-space char on line
0, $     Start and end of line.

g^       First non-space char of screen line.
g0, g$   First, last char of screen line.

gm       Go to the middle of the screen line.

|        Go to specific column (e.g. 16|)

f        Find occurence of char (e.g. 2fo)
F        As above, but backwards

t, T     Till (opposite inclusivity)

;        Repeat f,t,F,T (count times)
,        Repeat f,t,F,T in opposite direction.

Left/Right (wordwise)

w, W     Word forwards, (w relaxed delims)
e, E     End of word (e relaxed delims)
b, B     Word backwards (b relaxed delims)
ge, gE   Backwards to end of word.

Up/Down (linewise)

k, j     Up, down
gk, gj   Up, down screen lines

-, +     Up, down to first non-blank char

gg, G    First, last line or count-goto.

Operators commands

Operators compose with commands to convey intent. Example: 'd' is an operator, 'aw' is a command. There are 'a' commands and 'i' commands, and put with an operator we can say things like 'daw' and 'diw', for delete a word and delete inner word respectively. Using 'a' commands removes whitespace, whereas 'i' commands affect only the actual text.

Some 'a' and 'i' commands

aw, iw, aW, iW    Various word-related commands.
as, is, ap, ip    Sentence and paragraph commands.
at, it            Tag-related commands (e.g. <p>...</p>)
a", a', a`        Various quote related commands.
i", i', i`

Combine with these Operators

c       Change
d       Delete
y       Yank
~, g~   Swap case
gu, gU  Lowercase and Uppercase
!       Filter through external program
gq      Text formatting
<, >    Shift left and right
zf      Define a Fold
g@      Call function (see operatorfunc option)