In c mode, C-c C-c
will put marked text in comment.
In python mode, C-c C-c
will execute a python runtime.
Usually how do experienced emacs users resolve this inconsistency of key shortcut? Or we just accept it as is?
Emacs Stack Exchange is a question and answer site for those using, extending or developing Emacs. It only takes a minute to sign up.
Sign up to join this communityThere is no recommended way to resolve such an "inconsistency". Major modes are free to define C-c C-c
as they see fit. And users are free to bind it to whatever they like, overruling what a major mode defines.
Things between modes are often "inconsistent", because modes can differ dramatically.
Search for C-c C-c
in the Emacs manual, and you will see that what it does varies widely from mode to mode - very widely. If such "inconsistency" bothers you, bind it to something that does the same thing or something similar in all modes.
The only convention in effect that applies to C-c C-c
is this one, from the Elisp manual, node Key Binding Conventions
:
Sequences consisting of `C-c' followed by a control character or a digit are reserved for major modes.
C-c C-c is generally used to run interpreted code, but as C is not interpreted, it was assigned to a different function. But one of the best features of emacs is to customize it to make it behave just like you want, so if you wish to you can change the shortcut for C modes with:
(define-key c-mode-map "\C-c\C-c" 'your-function-of-choice)
C-c C-c
to something likecomment-region
, but with the advent ofcomment-dwim
in Emacs-21, bound toM-;
globally,these bindings were made redundant and disappeared. NowadaysC-c C-c
is mostly used for a command you run where you're done editing and want to send the result for processing. IOW the CC-mode binding is a remnant of a distant past and should just be removed (or replaced with a binding to something likecompile
). I suggest you file a bug report about it.