iTerm2 设置光标移动快捷键

本文介绍两种在iTerm2中实现快速跳转单词及行首尾的方法:一是选择预设的自然文本编辑模式;二是手动映射快捷键,包括左移光标、右移光标、行首、行尾等操作。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Copied from How to get Cmd-left/right working with iTerm2 and Vim (without requiring .vimrc changes)?

To jump between words and start/end of lines in iTerm2 pick one of the two solutions below.

1. Simple solution (recommended)

  1. Open Preferences
  2. Click “Profile” tab
  3. Select a profile in the list on the left (eg “Default”) and click “Keys” tab
  4. Click the “Presets” dropdown and select “Natural Text Editing”

2. Mapping keys manually (Advanced)

If you don’t want to use the “Natural Text Editing” preset mentioned above, you can map the keys you need manually:

  1. Open Preferences
  2. Click “Keys” tab
  3. Click the [+] icon

You can now add the following keyboard shortcuts:

Move cursor one word left

  • Keyboard shortcut: +
  • Action: Send Hex Code
  • Code: 0x1b 0x62

Move cursor one word right

  • Keyboard Combination: +
  • Action: Send Hex Code
  • Code: 0x1b 0x66

Move cursor to beginning of line

  • Keyboard Combination: +
  • Action: Send Hex Code
  • Code: 0x01

Move cursor to end of line

  • Keyboard Combination: +
  • Action: Send Hex Code
  • Code: 0x05

Delete word

  • Keyboard Combination: + ←Delete
  • Action: Send Hex Code
  • Code: 0x1b 0x08

Delete line

  • Keyboard Combination: + ←Delete
  • Action: Send Hex Code
  • Code: 0x15

Undo

  • Keyboard Combination: + z
  • Action: Send Hex Code
  • Code: 0x1f

Don’t forget to remove the previous bindings:

  • Open the “Profiles” tab
  • Click the sub-tab ”Keys”
  • Remove the mappings for key combinations + and +
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值