← All lessons

9. Operators Motions And Text Objects

Step 1 of 6

Editing text with Vim is like speaking a language

One of the biggest differentiators between Vim and other text editors is how Vim encourages its users to speak a language for editing text. We’ve already seen some examples of this language in the course so far without even realising — this time, we’re going to dive deep.

Fluency in other text editors might be quantified by how many shortcuts you have memorised. Vim is quite different — it’s not about how many key bindings you can remember, but instead about how effectively you can speak to the editor. In Vim, you have a vocabulary of commands, text objects, and motions, and you can communicate edits by combining these.

This really pushes the boundaries of what is possible. In Vim, if you learn just three operators and three text objects, you have a total of nine different actions you can carry out by combining the two together. If you start thinking about motions, there’s even more unique operations you can perform. The key here is that operators, text objects, and motions are composable. They are designed to work with each other.

None of this is not to say that the useful operations in Vim are not replicable in other editors — it’s just that Vim has a much more efficient interface for interacting with text that lets you do more with less.

As an example: let’s say you want to delete from the current cursor position to the next semicolon. In other editors, you’d probably either highlight manually from the current cursor position to the next semicolon, then hit backspace — or if you’re lucky, there’ll be a keyboard shortcut that does this for you. With Vim, you can think to yourself:

This is just a one example — similar edits pop up everywhere.

Let’s try this in the editor first. Place your cursor at the start of the indented line, and use dt; to delete to the first semicolon.

Loading editor…