Is there any way in the OS X Terminal to move the cursor word by word?

I know the combination Ctrl+A to jump to the beginning of the current command, and Ctrl+E to jump to the end.

But is there any way to jump word by word, like Alt+←/→ in Cocoa applications does?


开箱后,您可以使用相当离奇的Esc + F移动到下一个单词的开头,Esc + B移动到当前单词的开头。


On Mac OS X - the following keyboard shortcuts work by default. Note that you have to make Option key act like Meta in Terminal preferences (under keyboard tab)

  • alt (⌥)+F to jump F orward by a word
  • alt (⌥)+B to jump B ackward by a word
  • I have observed that default emacs key-bindings for simple text navigation seem to work on bash shells. You can use

  • alt (⌥)+D to delete a word starting from the current cursor position
  • ctrl+A to jump to start of the line
  • ctrl+E to jump to end of the line
  • ctrl+K to kill the line starting from the cursor position
  • ctrl+Y to paste text from the kill buffer
  • ctrl+R to reverse search for commands you typed in the past from your history
  • ctrl+S to forward search (works in zsh for me but not bash)
  • ctrl+F to move forward by a char
  • ctrl+B to move backward by a char
  • ctrl+W to remove the word backwards from cursor position

  • Here's how you can do it

    By default, the Terminal has these shortcuts to move (left and right) word-by-word:

  • esc+B (left)
  • esc+F (right)
  • You can configure alt+← and → to generate those sequences for you:

  • Open Terminal preferences (cmd+,);
  • At Settings tab, select Keyboard and double-click ⌥ ← if it's there, or add it if it's not.
  • Set the modifier as desired, and type the shortcut key in the box: esc+B, generating the text 33b (you can't type this text manually).
  • Repeat for word-right (esc+F becomes 33f )
  • Alternatively, you can refer to this blog post over at textmate:

    http://blog.macromates.com/2006/word-movement-in-terminal/

    链接地址: http://www.djcxy.com/p/8680.html

    上一篇: 在Vim中上下移动整行

    下一篇: 在OS X终端中是否有任何方法来逐词移动光标?