I have started using emacs with -nw option - ctrl-home and ctrl-end don't work

In order to speed up my emacs work flow, I am trying out emacs -nw versus running in X-Windows mode.

Ctrl-HOME and Ctrl-END are not working at all, and have tried editing .keymap files and following online advice has led to no joy unfortunately. E.g.

http://www.emacswiki.org/emacs/CuaMode

I usually enable cua-mode for shift-selection and this also fails when shift-paging up/down e.g.

It would be great to get all this working in -nw mode and I would welcome advice from fellow emacs users.

  • Install = Linux Mint 9
  • Shell = zsh

Unfortunately different terminals send different escape sequences for keys like Ctrl+Home, and Emacs doesn't know about all of them. You can declare additional escape sequences through function-key-map (or local-function-key-map under Emacs 23). This tells Emacs that these escape sequences are really an encoding for a single function key.

To find out what escape sequence a key sends, press C-q followed by the key: this will insert the escape character that begins the key sequence literally, followed by the other characters that make up the key sequence. For example, one terminal that I use sends the four characters ^[, O, 5, H when I press Ctrl+Home, so I would include the following line in my .emacs:

(define-key function-key-map "\e05H" [C-home])

\e is the most readable way of writing the escape character. Do the same for other keys you want to support.

If the keys aren't supported out of the box by the latest version of Emacs, it would be nice to tell the developers about the key sequences that your terminal sends.


I almost always run emacs with -nw. In order to scroll to the end of the file, I use M-S-, and M-S-. to get back to the start (maybe easier to remember as Alt-< and Alt->). Not quite as convenient as C-Home and C-End perhaps, but I prefer to work from the terminal (actually from within a tmux session, for what it's worth).


I wrote an Emacs package which can teach Emacs and terminals how to properly recognize all PC keyboard keys and modifier key combinations:

https://github.com/CyberShadow/term-keys

For cua-mode and Shift-selection, being able to use Ctrl + Shift + arrow keys is certainly an improvement.