In OSX I can just hold down the option key and press the left cursor key until I get to the word I need to edit (or in Vi I can just hit b, but I haven't been able to figure out how to do this in Terminal yet...

  • You can see the full list of readline bindings on this page, including instructions how to customize your own bindings.
    – jasonwryan
    Commented Jul 9, 2012 at 6:46

3 Answers 3


To set the key binding: You first have to find out what key codes the Ctrl+Left key sequence creates. Just use the command cat to switch off any interference with existing key bindings, and then type the key sequence. In my system (Linux), this looks like that:

$ cat

Press Ctrl+d to exit cat. Now you have found out that Ctrl-Left issues 6 key codes:

  • Escape (^[)
  • [
  • 1
  • ;
  • 5
  • D

Now you can issue the bind command:

bind '"\e[1;5D": backward-word'
  • 8
    You can add `` "\e[1;5D": backward-word '' into $HOME/.inputrc for permanent effect if you want .
    – llhuii
    Commented Jul 9, 2012 at 11:57
  • @llhuii +1, I forgot to mention that! Commented Jul 9, 2012 at 13:45
  • 2
    +1 for the most flexible way to bind arbitrary key combinations anywhere!
    – Irfy
    Commented Jun 18, 2013 at 12:23
  • if-my-word-contains-dashes - can I create a hotkey for a such? Commented Oct 17, 2023 at 14:22

The bash function you want is backward-word. You can run bind -q backward-word to get a list of keys bound to that function. One common binding is Esc+b

Also, many terminals support Ctrl+Left (the same hotkey you can use in X to jump backwards by word)

  • 1
    Ok, it returns backward-word can be invoked via "\eb". but how do I bind control+Left instead of Esc+b? Also, one drawback to Esc+b I can already see is that I have to let up on the Esc key every time I can to go back a word, isn't there a better way?
    – nipponese
    Commented Jul 9, 2012 at 7:13
  • 1
    Is there a better way? Naturally: set editing-mode vi :)
    – jasonwryan
    Commented Jul 9, 2012 at 8:00
  • 5
    @nipponese "esc b" can also be used on the keyboard as ALT-b. This may need to be specifically the left or right alt depending on your configuration, so try both.
    – Random832
    Commented Jul 9, 2012 at 13:00

The default key shortcut in Bash for backword-word is Alt + b . The same result can be achived with Esc + b . You should give those a try before editing your keybindings.

Use bind command to edit or bind -q [name] to get the current keybind of a specific action.

  • 2
    ... and forward - Alt + f
    – Putnik
    Commented Jun 4, 2016 at 15:23

You must log in to answer this question.

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