A chantastic guide to supermotions

I love keyboard effeciency.
It’s fun picking up simple motions that let you talk with a computer — more freely.

These motions aren’t limited to just one tool, or platform.
Everything here is intended to travel withy you, wherever conjuring computers takes you.


Change text

If I could take only one Vim motion with me everywhere, it would be change.
There’s just nothing like it in any other editor.

Just think about what’s involved in changing portions of text in most editors.

  • Move from keyboard to mouse
  • Make text selection
  • Move from mouse back to keyboard
  • Hit delete
  • Start typing

This is too many steps.
And it gets worse when the change you’re attempting is structural, changing surrounding double-quotes to single-quotes.
Or, in programming, changing strings to a variable.

Using Vim motions, can handle all of thise cases with the versital motion: c.

  • Change line (cc)
  • Change from here to the end of the line (C)
  • Change text inside quotes (ci”)
  • Change until the next , character (ct,)
  • Change quotes to curly braces (cs”{)
  • Change this paragraph (cap)

Of course to use these motions, you’ll need a quick primer on modal editing.
Let’s get started.

If you’ve never used Vim, this is a quikc primer.
Skip ahead if you’re already familiar with the concept.
Or stick around and learn how to explain it to a friend.

Every editor you’ve used before has a single mode: Insert mode.
You see a tall, skinny cursor.
And as you type, text is inserted.

In these editors, you run commands by prefixing charactors with a special key.

  • + x to cut
  • + c to copy
  • + v to paste

In Vim, this is achieved a different way.
You don’t use a prefix key; you leave insert mode, into a “macro mode” (called Normal mode — arrogantly enough).

In Normal mode, every key is an editing macro.

  • d to delete
  • c to change (delete and insert)
  • y to copy (“yank”)

And these macros allow you to specify range and selection:

  • dd - delete the current line
  • D - delete from the current position onward
  • di” - delete inside double quotes
  • dinq - delete inside next quate (single or double)

Change in: character pair

The change in: character pair supermotion targets text surrounded by a pair of characters.
In most cases, this is a pair quotes, paretheses, braces, or brackets.

Here are several common commands for this supermotion:

MacroDescription
ci”change in double quotes
ci’change in single quotes
ci`change in backticks
ciqchange in quotes (single or double)
ci(change in parentheses
ci{change in curly braces
ci[change in square brackets
ci<change in angle brackets
citchange in tag (HTML, XML)

Standard behavior

This supermotion operations in the character pair around your cursor.

But if your cursor is not is not in between the specified character pair, this supermotion works on the next character pair on that line.

It does not work backwards — even if the character pair (before the cursor) is the only character pair on the line.

But there is a macro modifier for this case.

Change inside modifiers

ModifierExampleDescription
nextcin<character>change in next <character>
lastcil<character>change in last <character>

Conclusion

Change in (ci) is my favorite, most used supermotion.
It saves so much effort in making text selections.


Change to

The “change to” supermotion deletes text untel the provided characters and re-enters Insert mode.

Here’s a the most common change inside macros:

MacroDescription
ci”change inside double quotes

vim supermotions

  • destructive insert
    • change partial text object (til)
    • change line (C)
    • change partial line
    • (visualizing selections, understanding motion)
  • positional insert
    • above and below
    • begging of line
    • first character
    • end of line
  • jump to occurrence
    • next
    • previous