Skip a word in the terminal on Mac OS

- Posted in development workflow

This is about terminal text navigation on Mac OS.

I knew I could use Ctrl + A and Ctrl + E to jump to the beginning of a line and the end of a line respectively.

Turns out you can also use Esc + B or Esc +F to jump to the beginning or the end of a word. These shortcuts are quite bizarre and require either very large hands or a lot of finger gymnastics.

What you can do to provide a better option is first to make sure the “Use option as meta key” is checked in Terminal settings (⌘+.)…

Using the Pro theme, naturally.

… and then you can use ⌥+B and ⌥+F to move between words.

I am learning some MongoDB and it’s quite useful to jump between words when you are navigating through longer strings:

So try to insert a long string:

db.tours.insert({ "tourName":"The Wines of Santa Cruz", "tourLength": 3, "tourDescription: "Discover Santa Cruz's wineries")}

And then use ⌥+B to move backwards through the words.

Now, how to remember this? (A mnemonic device)

  • Ctrl+E: End of line
  • Ctrl+A: A is the first letter of the alphabet, so it’s the start (this one is a bit weird)
  • ⌥+B: Back
  • ⌥+F: Forward

Edit: turns out you can also use Ctrl+B and Ctrl+F to skip a character. Cool!

Leave a Reply

Your email address will not be published. Required fields are marked *