Why is Ctrl+M bound to Enter in Ubuntu Jaunty? How to turn it off?
I\'m using Emacs and would like to bind Ctrl+M to some other command.
It's unclear whether the previous answers have solved this question, so here's another spin on it:
Historically, "return" frequently meant two things: Carriage Return, and Line Feed.
Quoting wikipedia:
Originally, carriage return was the term for a mechanism or lever on a typewriter that would cause the cylinder on which the paper was held (the carriage) to return to the left side of the paper after a line of text had been typed, and would usually move the paper to the next line as well. Later it was used for the control character in Baudot code on a teletypewriter for end of line return to beginning of line and did not include line feed.
Long story short, there are two ASCII codes that are relevant to end-of-line (and, therefore, potentially to the return key): CR (ASCII decimal 13, or Ctrl-m) and LF (ASCII decimal 10, or Ctrl-J).
I think the general convention these days is for the return or enter keys to map to ASCII 13, and thus be "return" (RET
in emacs messaging). But if you're running emacs from a terminal emulator, this may mean that you don't have the option of having a C-m binding that's different from RET
. When I try running emacs in a terminal (GNU Emacs 23.2.1 on MacOS X in Terminal.app), and I try typing C-h c
RET runs the command newline
If I type, instead, C-h c C-m (i.e. holding down control and pressing M), I get:
RET runs the command newline
In other words, the exact same thing. Emacs (nor any other program run from the terminal) can't tell the difference between the two. (Knowing this can sometimes be handy -- if you're logged in to a system that maps things differently than the system you're coming from, you can type C-m or C-j to get the thing you want, depending on the way the mapping is screwed up.)
And speaking of having the mapping screwed up, I'll just mention that there are some stty
settings that can be relevant to such things: inlcr
, inlcr
, and igncr
(these three are related to how input is processed -- there are also some output-related ones). I doubt that making stty changes is going to be useful to this particular problem, but I thought it worth mentioning.
In the end, I think your choices are:
Live with not having C-m that means anything different than return/enter
Run a graphical version of emacs, instead of the terminal version. This should have access to the distinct keycodes, which the terminal emulator isn't passing along (because it's emulating a terminal, which didn't have such things in the same way as modern computers do).