If you like to edit code with Vim (or if you've played too much nethack) then you probably enjoy the convenience of moving the cursor around with the h j k l keys.
In iTerm2, it's pretty simple to map those keys to behave the same way. In my case, I decided that whenever I held down
Control and pressed h j k l then I should get Vim movement in my terminal.
To set this up
- go to Preferences > Keys in iTerm2
- click the plus button at the bottom to new Global Shortcut Keys for each mapping
- Enter the keyboard shortcuts you'd like to use, such as control+h and so on
- Set the Action to Send Escape Sequence and set the Esc+ field to one of the following for each arrow key:
Up: [A Down: [B Right: [C Left: [D
The escape sequences were found using
sed -n l then pressing each arrow key. The
^[ prefix is automatically added by iTerm2 keymapping, so the last two characters in the escape sequence are all that's necessary.
If you happen to use Sublime Text 3 and you'd like to enable this sort of movement, check out my protip here: https://coderwall.com/p/rvekkq
Edit: If you want this for any application, try http://www.keyboardmaestro.com - I set these keys up in Chrome as well :)