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.

3 Answers 3


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


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

  • what about iTerm?
    – andilabs
    Jul 21, 2022 at 6:55

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .