1

I'm very new to emacs and essentially came from vim where it is not possible to bind CTRL-num combination like (CTRL-1, CTRL-2, etc) which as well as CTRL-SHIFT-xxx like CTRL-# which essentially works as simply #.

Is something like this possible in emacs?

2

It is perfectly possible to bind C-digit, at least in a "graphical terminal". In a text terminal, things may be different because the terminal may itself generate characters from a key combo, which then can't be seen by emacs. See this answer for discussion and links.

Actually, C-0, C-1 etc are already bound in the global map, as can be seen with the command describe-key:

M-x describe-key CTRL 1

C-1 runs the command digit-argument (found in global-map), which is an interactive compiled Lisp function in ‘simple.el’.

It is bound to C-9, C-8, C-7, C-6, C-5, C-4, C-3, C-2, C-1, C-0, ESC 0..9, C-M-9, C-M-8, C-M-7, C-M-6, C-M-5, C-M-4, C-M-3, C-M-2, C-M-1, C-M-0.

(digit-argument ARG)

Part of the numeric argument for the next command. C-u following digits or minus sign ends the argument.

You can rebind it, eg:

(global-set-key [(control ?1)] 'save-buffer)

You can do the same for #:

(global-set-key [(control ?#)] 'save-buffer)

For information on how to rebind keys, see the elisp manual chapter on keymaps.

2

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.