How to turn off alternative Enter with Ctrl+M in Linux

前端 未结 8 937
广开言路
广开言路 2021-02-04 06:37

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.

8条回答
  •  旧巷少年郎
    2021-02-04 06:54

    I think your question is backwards. It is not C-m that is bound to Enter, it is Enter that is bound to C-m. And C-m is the same as RET.

    If you run C-h k C-m, you will see something like "RET runs the command ...". C-m sends RET because it is a control code, see http://en.wikipedia.org/wiki/Control_character.

    The Enter key is bound to C-m; if you run C-h k Enter, you will see something like "RET (translated from ) runs the command ...". See, Enter is being interpreted by emacs as and then that key is getting translated to C-m.

    What you want to do is first remove the translation from to RET by binding it directly to what it's currently indirectly bound, e.g. (global-set-key (kbd "") 'newline). Then you're free to bind C-m to whatever you want without affecting Enter.

    This assumes you're using the graphical emacs. If you're running it in a terminal, this won't work, because Enter will send C-m, not . You can check that using the window-system variable though.

提交回复
热议问题