4

I would like to override the C-c C-j keybinding. I put this in my init file

 (global-set-key (kbd "C-c C-j") 'counsel-org-goto)

However, it won't override the command org-goto (found in org-mode-map).

Thanks for your input!

2

1 Answer 1

5

Try this expression:

(with-eval-after-load "org"
  (define-key org-mode-map (kbd "C-c C-j") #'counsel-org-goto))

The Org mode keymap "shadows" the global map. In Emacs, the keymaps of major modes take precedence over keybindings in the global keymap.

See this excellent tutorial from Mickey Petersen for a thorough discussion of the "keymap lookup order": https://www.masteringemacs.org/article/mastering-key-bindings-emacs.

2
  • Thanks Phil, that's better.
    – Tom Davey
    Commented Jul 13, 2021 at 17:42
  • This worked like a charm! I understand the logic. Thanks so much.
    – Adelita
    Commented Jul 14, 2021 at 8:54

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.