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

前端 未结 8 858
广开言路
广开言路 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 07:05

    Some very good explanations here as to the nature of the problem, and I won't expound on those issues. However, I want to address the original question directly. I solved the problem for changing the (control m) sequence bound to 'newline command by the following code in my ~/.xemacs/custom.el file:

    (defun my-compile-hook-for-c-and-cpp-mode ()
      "My compile hook for C and C++ mode" 
      (local-set-key [(control m)] 'compile)
      )
    
    (add-hook 'c-mode-hook 'my-compile-hook-for-c-and-cpp-mode)
    (add-hook 'c++-mode-hook 'my-compile-hook-for-c-and-cpp-mode)
    

    In the above example, I have changed (control m) to run the 'compile command (M-x compile) when the c-mode or c++-mode is active.

    Note that you can change the behavior of (control m) globally as well, without the mode related bindings. In that case, just add the following to your ~/.xemacs/custom.el file:

    (global-set-key [(control m)] 'compile)
    

提交回复
热议问题