Move Cursor Word by Word in Terminal for Mac OS X
If you spend a lot of time at the command line, you undoubtedly find yourself adjusting and editing text and commands, and you likely often need to move the cursor to a further position in the Terminal from where it’s actively located. Sure you can use the arrow keys to move left and right on a per-character basis, or you can use the handy put cursor at mouse position trick, but another option is to move the cursor position word by word in Terminal, skipping back or forward by entire word blocks rather than individual text characters.
There are a few ways to achieve this, but the easiest which requires no modifications to the Terminal uses a longstanding series of two different keyboard shortcuts:
Move Cursor Forward by Word in Terminal: Escape + F
Escape F moves the cursor forward a word at the command line.
Move Cursor Backward by Word in Terminal: Escape + B
Escape B moves the cursor backward by a word at the command line.
Moving forward and back word by word at the command line with these two keystrokes is demonstrated in the simple animated GIF below:
These two keystrokes have been around at the command line for ages, and so though they certainly work to navigate by word block in the Mac OS X Terminal, they should also work in just about any other unix based terminal you come across as well.
There are also two Mac OS specific keystrokes to navigate in text word by word forward and backward in Mac OS X Terminal and in most other Mac apps too:
Option + Left Arrow Moves Cursor Left by a Word in Mac OS X Terminal
Option / ALT and the Left Arrow will also move the cursor position left by a word throughout Mac OS.
Option + Right Arrow Moves Cursor Right by a Word in Mac Terminal
Option / ALT and the Right Arrow will send the cursor position right by a word throughout Mac OS as well.
Remember, the option key is the ALT key on Macs, and vice versa, though some models and regions will label them differently they are always the same key.
You shouldn’t need to make any adjustments to terminal for the option tricks to work either, but if you find they are not working in Terminal app you may have better results with enabling Option as Meta key in Terminal for Mac.