如何使用Shift +箭头在iterm中选择文本?

tru*_*ess 21 macos terminal iterm iterm2

在大多数mac应用程序中,Shift + Arrow选择文本但在iterm中它只是移动光标而不选择.你如何选择文本?

如果有一种方法可以在terminal.app中执行此操作,也会很奇怪.

Mer*_*lin 13

按照此超级用户答案中的说明进行操作,该答案描述了使用iTerm自定义键绑定来映射⌥+ ⇧+ ←以按字词选择.它很聪明地在配置文件中进行新的键映射以测试它,而不是主键偏好.

建议的键绑定

的iTerm: Preferences > Profiles > Keys

单击+以添加键绑定,Click to Set

⌥+ ← | 操作:移动选择的开始>按字符移动

⌥+ →| 操作:向前移动选择结束>按字符移动

⌥+ ⇧+ ← | 操作:将选择的开始移回>按字移动

⌥+ ⇧+ →| 操作:向前移动选择结束>按字词移动


您⌘ C或⌘ V将要复制/粘贴这些选择

  • 我建议 **_disabling_** `常规 > 选择 > ✅ 自动进入复制模式...` (2认同)

小智 12

在iterm中它只是移动光标而不选择.你如何选择>文本?

是的,iTerm有一种特殊的文本选择技术.需要一点点习惯,但它比ol'"shift + arrow"mac OS方法更快.

如果要选择的文本位于当前会话的回滚中的任何位置,只需按?+ f然后键入要选择的前几个字符.iTerm将找到文本并突出显示它.

然后,点击tab将选择范围扩展到下一个单词的结尾,重复tab所需的次数以完全选择所需的文本.

如果您对选择感到满意,请继续打入您的(?+ c)+(?+ V)或者您有什么.

额外奖励:您还可以使用shift+ tab将选择范围向后扩展到上一个单词的开头.


dan*_*kos 12

要扩展@merlin 的答案,这里还有一些用于导航/删除的 iTerm2 键绑定

? Del | send hex 0x15 | delete line

? Del | send hex 0x1B 0x08 | delete word

? ? | send hex 0x01 | move a cursor to the beginning of a line

? ? | send hex 0x05 | move a cursor to the end of a line

? ? | send esc seq Esc+b | move a cursor to the left by word

? ? | send esc seq Esc+f | move a cursor to the right by word

? ? ? | move start of sel back by word | select to the left by word

? ? ? | move end of sel forward by word | select to the right by word