How to Move the Cursor Word by Word in Terminal on Your Mac

Many times it happens that you type a command in Terminal on your Mac and then need to make changes in the command. You then go back character by character to modify the command to then be able to execute it. While moving character by character in a Terminal command can be done using the arrow keys on your keyboard, moving the cursor word by word requires a different key combination.

The advantage of being able to move the cursor over words is that you can go really far through the command with just a few keystrokes. Here’s how to do that in Terminal on your Mac.

1. Launch Terminal on your Mac.

2. Type in a command in Terminal that has some words so you can do this procedure.

Once you have typed the command, use the following keys to move forward or backward word by word:

Esc + B – to move the cursor backward by a word

Esc + F – to move the cursor forward by a word

movecursor-move

The keystrokes above should work in almost all the Unix-based terminals. But, you also have Mac-specific key combinations that let you move the cursor the same way as above. Those are:

Option + Left Arrow – to move the cursor backward by a word

Option + Right arrow – to move the cursor forward by a word

That’s how to move forward or backward by a word in Terminal on your Mac. If Terminal happens to be the app you use often, the tip above should help you make your work a little easier.

One comment

  1. In iTerm2, which I use instead of Apple’s terminal, ESC + B/F works as described. Sadly, though, Option + Left/Right Arrow (which I would have preferred to use) doesn’t work. Oh, well, at least one of them does. Thanks for teaching me something new and quite useful today :-)

    It’s also probably worth mentioning that there are also short-cuts for getting to the beginning and end of the command line. In both iTerm2 and Apple’s terminal, Control + A goes to the beginning and Control + E to the end. In Iterm2, one could also use FN + Left Arrow to go to the beginning and FN + Right Arrow to go to the end.

Comments are closed.

Sponsored Stories