iTerm 2: How to set keyboard shortcuts to jump to beginning/end of line?

后端 未结 14 1631
难免孤独
难免孤独 2020-12-02 03:09

I can see that Ctrl+left/right jumps to the beginning/end of line. How to change this to Cmd+left/right arrow

相关标签:
14条回答
  • 2020-12-02 04:02

    Follow the tutorial you listed above for setting up your key preferences in iterm2.

    1. Create a new shorcut key
    2. Choose "Send escape sequence" as the action
    3. Then, to set cmd-left, in the text below that:
      • Enter [H for line start
        OR
      • Enter [F for line end
    0 讨论(0)
  • 2020-12-02 04:03

    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 +
    0 讨论(0)
提交回复
热议问题