Saturday, March 28, 2015

Ctrl-down/up in emacs in Mac Terminal

Finding the answer to this online pretty much drove me nuts. I'm sharing it here for you, future Internet user.

Here's the situation:
  • I use Emacs
  • I use Emacs in the Mac Terminal
  • \C-down was bound to forward-paragraph by default (and \C-up bound to backward-paragraph by default).
  • I wanted them to actually work, but they didn't.
Through some series of trickery I was able to figure out that the Mac terminal was sending the wrong escape sequences for cltr-up and down. Specifically, it wasn't sending anything at all, beyond just the down key. I fixed it with the following settings:
  1. From the terminal, go to "Preferences" "Settings" "Keyboard"
  2. Look for and modify, or add actions for ctrl-up and ctrl-down:
    1. ctrl-up = \033[1;5A
    2. ctrl-down = \033[1;5B

2 comments: