Skip to content

Instantly share code, notes, and snippets.

@LucasKuhn
Last active May 9, 2023 10:37
Show Gist options
  • Save LucasKuhn/619345eb75dc3cfeaac3d23833a71ac5 to your computer and use it in GitHub Desktop.
Save LucasKuhn/619345eb75dc3cfeaac3d23833a71ac5 to your computer and use it in GitHub Desktop.

These are keymappings with extra options to travel iTerm2 the same way you would travel a code editor: Using option + arrow to travel words, option delete to delete a word, and command delete to delete a line.

Option 1 - Manually installing

Open Preferences -> Profile -> Keys and add these:

" ⌥ + ← " - Travel back a word - Send text with Vim characters: \033b
" ⌥ + → " - Travel forward a word - Send text with Vim characters: \033f
" ⌥ + del " - Delete a word - Send hex code: 0x1B 0x08
" ⌘ + del " - Delete line - Send hex code: 0x15

Option 2 - keymap file

You can open iTerm2, go to Preferences -> Profile -> Keys, click on import and import the .itermkeymap file below

{"Key Mappings":{"0xf700-0x260000":{"Text":"[1;6A","Action":10},"0x37-0x40000":{"Text":"0x1f","Action":11},"0x32-0x40000":{"Text":"0x00","Action":11},"0xf709-0x20000":{"Text":"[17;2~","Action":10},"0xf70c-0x20000":{"Text":"[20;2~","Action":10},"0xf729-0x20000":{"Text":"[1;2H","Action":10},"0xf72b-0x40000":{"Text":"[1;5F","Action":10},"0xf705-0x20000":{"Text":"[1;2Q","Action":10},"0xf703-0x260000":{"Text":"[1;6C","Action":10},"0xf700-0x220000":{"Text":"[1;2A","Action":10},"0xf701-0x280000":{"Text":"0x1b 0x1b 0x5b 0x42","Action":11},"0x38-0x40000":{"Text":"0x7f","Action":11},"0x33-0x40000":{"Text":"0x1b","Action":11},"0x7f-0x100000-0x33":{"Label":"","Action":11,"Text":"0x15"},"0xf703-0x220000":{"Text":"[1;2C","Action":10},"0x7f-0x80000-0x33":{"Label":"","Action":11,"Text":"0x1B 0x08"},"0xf701-0x240000":{"Text":"[1;5B","Action":10},"0xf70d-0x20000":{"Text":"[21;2~","Action":10},"0xf702-0x280000-0x7b":{"Label":"","Action":38,"Text":"\\033b"},"0xf702-0x260000":{"Text":"[1;6D","Action":10},"0xf729-0x40000":{"Text":"[1;5H","Action":10},"0xf706-0x20000":{"Text":"[1;2R","Action":10},"0x34-0x40000":{"Text":"0x1c","Action":11},"0xf700-0x280000":{"Text":"0x1b 0x1b 0x5b 0x41","Action":11},"0x2d-0x40000":{"Text":"0x1f","Action":11},"0xf70e-0x20000":{"Text":"[23;2~","Action":10},"0xf702-0x220000":{"Text":"[1;2D","Action":10},"0xf703-0x280000-0x7c":{"Label":"","Action":38,"Text":"\\033f"},"0xf700-0x240000":{"Text":"[1;5A","Action":10},"0xf707-0x20000":{"Text":"[1;2S","Action":10},"0xf70a-0x20000":{"Text":"[18;2~","Action":10},"0x35-0x40000":{"Text":"0x1d","Action":11},"0xf70f-0x20000":{"Text":"[24;2~","Action":10},"0xf703-0x240000":{"Text":"[1;5C","Action":10},"0xf701-0x260000":{"Text":"[1;6B","Action":10},"0xf72b-0x20000":{"Text":"[1;2F","Action":10},"0x36-0x40000":{"Text":"0x1e","Action":11},"0xf708-0x20000":{"Text":"[15;2~","Action":10},"0xf701-0x220000":{"Text":"[1;2B","Action":10},"0xf70b-0x20000":{"Text":"[19;2~","Action":10},"0xf702-0x240000":{"Text":"[1;5D","Action":10},"0xf704-0x20000":{"Text":"[1;2P","Action":10}},"Touch Bar Items":[]}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment