macos 在 iTerm2 或 OSX Lion 中的终端中跳词

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6801594/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 08:12:55  来源:igfitidea点击:

Word jumping in iTerm2 or Terminal in OSX Lion

macosterminalkeymapping

提问by Carson

I recently upgraded from Snow Leopard to Lion and Xcode 4.1, and word jumping stopped working in both Terminal and iTerm2. Did the mappings change?

我最近从 Snow Leopard 升级到 Lion 和 Xcode 4.1,并且单词跳转在 Terminal 和 iTerm2 中都停止工作了。映射改变了吗?

This is with andwithout a homebrew installation of readline.

这是有没有自制安装的readline.

My .inputrclooks like this:

我的.inputrc看起来像这样:

"\e[1;5D": backward-word
"\e[1;5C": forward-word

Thanks!

谢谢!

采纳答案by Carson

mission control took over the same commands as word jumping. thanks to rob cowrie and nicholas riley for the heads-up on that.

任务控制接管了与单词跳跃相同的命令。感谢 rob cowrie 和 nicholas riley 提供的提示。

回答by Nik

Just add the escape sequences in iTerm settings as global shortcut keys.

只需将 iTerm 设置中的转义序列添加为全局快捷键即可。

Word backward (option-arrowleft):

单词向后(option-arrowleft):

a iTerm settings

iTerm 设置

Same with word forward, just use F.

与 word forward 相同,只需使用F.

回答by typingduck

The easiest/quickest way I have found is under Profiles > Keys > 'Load Preset...' > 'Natural Text Editing'.

我发现的最简单/最快的方法是在 Profiles > Keys > 'Load Preset...' > 'Natural Text Editing' 下。

Then use the optionkey rather than the controlkey.

然后使用option钥匙而不是control钥匙。

(iterm2 version 3)

(iterm2 版本 3)

回答by best wishes

Killing a fly with a cannon:

用大炮杀死一只苍蝇:

  • Go to Preferences...> Profiles> Keys
  • Press Load Preset...
  • Select Natural Text Editing
  • 转到首选项...>配置文件>
  • 加载预设...
  • 选择自然文本编辑

Then, you can move a word backwards using Option ?+ and a word forwards using Option ?+ , move to the start of the line using fn+ and to the end of the line with fn+ . Also you can delete a word backwards using Option ?+ ?, delete the whole line using Command ?+ ?.

然后,您可以使用移动一个字向后Option ?+和向前用字Option ?+ ,移动到使用该行的开始fn+ ,并与行的末尾fn+ 。你也可以使用删除一个字向后Option ?+ ?,使用删除整行Command ?+ ?

If the preset doesn't appear, reinstall iTerm2. If you installed it using Homebrew+Cask:

如果没有出现预设,请重新安装 iTerm2。如果您使用 Homebrew+Cask 安装它:

brew cask reinstall iterm2

source and credits https://apple.stackexchange.com/a/293988/330806

来源和学分https://apple.stackexchange.com/a/293988/330806

回答by Olivier Refalo

I added the following in my /etc/inputrc

我在 /etc/inputrc 中添加了以下内容

# word jump on SHIFT left/right arrows
"\e[1;2D": backward-word
"\e[1;2C": forward-word

it works great

效果很好

回答by Thomas Chen

Following the steps listed in the above answers, I found that on my laptop the first bash (1.bash) will not be able to jump words by pressing option + arrow. Instead, it will simply type in "[D","[C". However, if I create a new bash window (2. bash), the word jump works.

按照上述答案中列出的步骤,我发现在我的笔记本电脑上,第一个 bash (1.bash) 将无法通过按 option + 箭头来跳转单词。相反,它会简单地输入“[D”、“[C”。但是,如果我创建一个新的 bash 窗口 (2. bash),则跳转这个词会起作用。