Ask Different is a question and answer site for power users of Apple hardware and software. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am at the command line and I have

. /this/set/of/directory/this_command "parm1", "parm2", "parm3"

When I 'up-arrow' to recall previous lines, how can I move along the line from "word to word". Ideally a directory separator slash ("/") will also count as word demarcation.

On other OS's I can use things like ctrl-[left/right]arrow or alt-[left/right] arrow to move "a word at a time" but I haven't yet found any keystroke combination on a mac that will let me do that.

share|improve this question
up vote 2 down vote accepted

As a general solution for the bash shell (Linux/Mac) : I set the Vi mode with

$ set -o vi

I have set it in the global /etc/bashrc file.

That way I can navigate with the usual vi keys within a command line after hitting the ESC key.

E.g. changing into Vi mode and then by pressing 'b' I can move back a word. And since the directory seperator counts as a word seperator it would work for your example.

Typing 'w' would move to the right again by a word each time. And so on

share|improve this answer

In Terminal, you can use opt-[left/right] arrow to navigate word by word. Additionally, you can use opt+click to reposition the cursor.

share|improve this answer

If you'd prefer not to switch to vi mode, you can check “Use option as meta key” under Preferences… > Settings > any profile > Keyboard. With that enabled you'll be able to hit Opt+B & Opt+F to move backward & forward a word at a time, along with a plethora of other emacs-style shortcuts.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.