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.


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.

| improve this answer | |

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).

| improve this answer | |

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


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

| improve this answer | |

You may try another terminal. On centos7, with emacs 25.3, ctrl-home doesn't work in mate-terminal, but works with gnome-terminal. It also work inside screen (with gnome-terminal) off topic tip: I just discovered (xterm-mouse-mode 1), it's great!

| improve this answer | |

Do yourself a favour and do the tutorial :)

emacs by default uses classic line editor bindings.

Ctrl a  << to start of line
Ctrl e  >> to end of line
Ctrl k  cut to end of line
Ctrl y  yank that back
alt y   roll back one more yank (repeat) try it out to get it.

They are the ones I use the most and these also work with readline (most shells)

Google or dig around on your system for cheat sheets.


| improve this answer | |
  • 1
    Good for you @petergozz, I wanted to use Ctrl-HOME and Ctrl-END as the original question asked. Thanks for trying to help, but I have been using Emacs 20 yrs and didn't need a refresher course on line editor bindings per se. My enquiry was specifically about running Emacs in my terminal environment and the idiosyncrasies of that situation. Ctrl a << to start of line? Are you serious? – codeasone Apr 19 '12 at 7:14
  • Oops Sorry. Oh there is no << that's just sugar. – petergozz Jun 25 '12 at 16:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.