bash 在 Mac 上使用 iTerm2,如何在命令行上从光标中删除一个单词?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12335787/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
With iTerm2 on Mac, how to delete forward a word from cursor on command-line?
提问by qazwsx
With iTerm2 1.0.0 on Mac OS X 10.6.8, I'd like to delete from cursor to the next end of word, i.e. deleting one word forward. I tried Alt+dbut this types the delta operator symbol ?and doesn't delete. How to suppress the typing but let it delete?
在 Mac OS X 10.6.8 上使用 iTerm2 1.0.0,我想从光标删除到单词的下一个结尾,即向前删除一个单词。我试过Alt+d但这会输入 delta 运算符符号?并且不会删除。如何抑制打字但让它删除?
回答by maxbellec
For this and other shortcuts go to preference -> profile -> keys, add the following shortcuts
对于此和其他快捷方式,请转到首选项 -> 配置文件 -> 键,添加以下快捷方式
?← : Send Escape Sequence Esc+ b
?← : 发送转义序列 Esc+ b
?→ : Send Escape Sequence Esc+ f
?→ : 发送转义序列 Esc+ f
?← : Send Escape Sequence Esc+ [H
?← : 发送转义序列 Esc+ [H
?→ : Send Escape Sequence Esc+ [F
?→ : 发送转义序列 Esc+ [F
?←Delete : Send Hex Code 0x15
?←删除:发送十六进制代码 0x15
?←Delete : Send Hex Code 0x1B 0x08
?←删除:发送十六进制代码 0x1B 0x08
http://elweb.co/making-iterm-2-work-with-normal-mac-osx-keyboard-shortcuts/gave me the tip
http://elweb.co/making-iterm-2-work-with-normal-mac-osx-keyboard-shortcuts/给了我提示
回答by Aleksandar Dimitrov
I don't have a mac handy, but ESC d should in theory do the same thing that ALT-d does.
我手头没有 mac,但理论上 ESC d 应该和 ALT-d 做同样的事情。
NOTE: this means hitting ESC, releasing it, then hitting d. Look ma, no key chords.
注意:这意味着按 ESC,释放它,然后按 d。看,没有关键和弦。
回答by Hal
Just to add to Alexsander's answer the easiest way to replicate this behaviour is to select the option "Left option key acts as +Esc" in the Preferences->Profiles-> Keys screen.
只是添加到 Alexsander 的答案中,复制此行为的最简单方法是在首选项-> 配置文件-> 键屏幕中选择选项“左选项键充当 +Esc”。
回答by Maroun
回答by Andy Wong
回答by Philip Claren
ctrl+dwas a forward delete for me in irband iexin iTerm2. But since I wanted to use the regular del key on the keyboard with the numpad, I looked for something else. And then I found a list of hex codes corresponding to ctrl+something key strokes: 4 is number and the number is 4. 
ctrl+d在 iTerm2中irb和iex在 iTerm2 中对我来说是一个前向删除。但是由于我想通过小键盘使用键盘上的常规 del 键,所以我寻找了其他东西。然后我找到了ctrl+something按键对应的十六进制代码列表:4是数字,数字是4。

