Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

change org-insert-heading shortcut

I would like to change the shortcut defined for org-insert-heading (in org-mode, in emacs).

It is M-<RET> and I would like to have C-c C-j (like in AUCTex mode).

How do I do this (there is no variable in org-customize) ?

like image 238
ppr Avatar asked Sep 26 '13 21:09

ppr


3 Answers

As an alternative to erikstokes' answer, you can use define-key with the appropriate keymap. Set this in your .emacs.d/init.el :

(define-key org-mode-map (kbd "C-c C-j") 'org-insert-heading)

This will add it to the org-mode keymap, and it will not add the key locally every time the mode is set to org-mode (it shouldn't matter, but running it on every hook can cause issues for some commands.

like image 175
Jonathan Leech-Pepin Avatar answered Nov 18 '22 23:11

Jonathan Leech-Pepin


You just need to bind C-c C-j to the function you want. Assuming that you only want it bound this way in org-mode, add

(add-hook 'org-mode-hook
      '(lambda ()
         (local-set-key "\C-c\C-j" 'org-insert-heading)
         ))

to your .emacs file and restart Emacs (or just reload your .emacs). Now every time you load a file in org-mode the local-set-key function will be run and set the keys the way you want.

like image 2
erikstokes Avatar answered Nov 18 '22 23:11

erikstokes


You could have a look at "org-auctex-keys.el", a minor mode which I created to offer AUCTeX key bindings within Org documents.

Check it out at https://github.com/fniessen/org-auctex-key-bindings.

like image 1
fniessen Avatar answered Nov 18 '22 22:11

fniessen