0

In general I have key bindings as follows:

(define-key isearch-mode-map (kbd "C-h") 'isearch-del-char)

Now I want to define a key binding for C-= (Control plus equal sign, which is next to Backspace on my keyboard); where it does not work.

Is it possible to do it?

4
  • 3
    Terminal emacs or GUI emacs? You may be able to do it in GUI emacs, but probably not in the terminal.
    – NickD
    May 6, 2020 at 14:25
  • I meant terminal emacs, I am not good with gui @NickD
    – alper
    May 6, 2020 at 18:11
  • 2
    Say C-h c C-= in your emacs and see what it says: if it says = runs the command self-insert-command then it does not recognize C-= (note that you asked it about C-= and it answered about =). If it says C-= is undefined then you should be able to change it.
    – NickD
    May 6, 2020 at 18:59
  • You are right, it returns as: = runs the command self-insert-command
    – alper
    May 7, 2020 at 1:27

1 Answer 1

1

Without more context, the direct answer to "is it possible to generate a keybinding for C-=" is "Yes".

For example,

(global-set-key (kbd "C-=") (lambda () (interactive) (message "Hello world!")))

There are many other ways. For instance, my init contains the following use-package definition:

(use-package expand-region
  :ensure t
  :bind (("C-=" . er/expand-region)
         ("C-+" . er/contract-region)))

Both of these define global keybindings.

Key map specific bindings can be defined like you state in the question. An example of this, again taken from my init, defines the <insert> key to insert an Org structure template only for buffers with Org mode enabled:

(define-key org-mode-map (kbd "<insert>") 'org-insert-structure-template)
1
  • 3
    That is possible on GUI emacs and maybe terminal emacs for some terminals, but certainly not all of them (e.g. try it in gnome-terminal with emacs -nw).
    – NickD
    May 6, 2020 at 19:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.