1.打开iTerm2的preferences-->profile-->Keys,将常用的左(或者左和又)Alt键设置为换码符(escape character)。如下图所示:
2.在Key mappings中找到已经存在的⌥ ←及⌥→,如果没有的话,就新建这两个快捷键。
修改这两个快捷键的设置。将⌥ ←的设置修改为如下内容:
Keyboard Shortcut: ⌥ ←
Action:Send Escape Sequence
Esc+: b
将⌥→的设置修改为如下内容:
Keyboard Shortcut: ⌥→
Action:Send Escape Sequence
Esc+: f
现在我们就可以在iTerm2中使用⌥ ←及⌥→移动光标跳过单词了。