Tuesday, 13 October 2020

iTerm2: 'Words - Forward, Backward and Delete' actions by word - Jump words in iTerm2

By default, iTerm2 doesn’t allow you to move/jump cursor over words. This works by default on Ubuntu and other Linux terminals. Let's try to enable them in the MAC OS - iTerm2 application.

  1. Jump cursor forward over words using keyboard shortcut ⌥+←
  2. Jump cursor backward over words using keyboard  shortcut ⌥+→
  3. Delete by word using keyboard shortcut ⌥+delete


Here’s how you can configure iTerm2 on Mac OS to allow you to do the above operations:

Open iTerm2 > Preferences > Profiles > Keys and add below shortcuts:

  • Add forward jump(#1):
    • Keyboard Shortcut: ⌥+←
    • Action: Send Escape Sequence
    • Esc+b
  • Add backward jump(#2):
    • Keyboard Shortcut: ⌥+→
    • Action: Send Escape Sequence
    • Esc+f
  • Enable delete by word (#3):
    • Navigate to the keyboard shortcuts section "iTerm2 > Preferences > Profiles > Keys"
    • Change setting "Left option(⌥) key" from 'Normal' to 'Esc+'
    • By changing this option, now you can use ⌥+delete to delete by word

Well done! Now you have all the 3 shortcuts enabled. This saves a lot while using the terminal for day to day activities. Have fun!



    No comments:

    Post a Comment

    Update node.js & npm packages to latest/stable/<version>

    Upgrade Node.js and npm: sudo npm cache clean -f  (force) clear you npm cache sudo npm install -g n  install  n  (this might take a while) s...