Vim motion

Special

. = Repeat previous sequence * = Search for word under caret = = Reindent selection == = Reindent line q = Record macro (advanced use) @ = Run macro (advanced use)

Actions

c = Change v = Select V = Select line r = Replace d = Delete D = Delete remainder of current line x = Delete (backspace) X = Delete (forwards) y = Yank (Copy) yy = Yank line (Copy) p = Paste (in front of caret) P = Paste (Behind caret)

Actions can usually be combined with context, and/or motion. Contexts I usually use: i = inner a = all or surrounding t = html tag b = block of parenthesis ()
B = block of squiggly brackets {}

Some examples: dit = Delete everything inside a tag.

Eg.:

1<span>Lorem ipsum</span>

Would become:

1<span></span>

_dt> = Goto beginning of line and delete until the next >

Result:

1></span>

Motions

h = Left j = Down k = Up l = Right f = Go forward (including char) t = Go to (excluding char) F = Go backwards (reverse f) T = Go backwards to (reverse t) w = Next word e = End of word b = Beginning of word _ = Beginning of line (excluding whitespace) 0 = Beginning of line gg = Beginning of file G = End of file % = Go to other end of matching character, ie.: (), {}, [] etc.. { = Previous paragraph } = Next paragraph ; = Repeat motion forwards , = Repeat motion backwards

Cmd + d replacement (multiline editing)

* Search for the next word to replace. N Go back to previous word (back to start). ciw Replace inner word, enters insert mode. Type the replacement then hit esc to go back to normal mode. n To go to next occurrence of the word. . Repeat the inner word replacement.

Misc

zz = Center screen to cursor

Written by Eivin Landa • May 8, 2024 • Updated May 10, 2024