7

I'm transitioning from VIM (using GNU Emacs 24.5.1). I want to move between "windows" using familiar keys i.e.

(global-set-key (kbd "C-k") 'windmove-up)
(global-set-key (kbd "C-j") 'windmove-down)
(global-set-key (kbd "C-h") 'windmove-left)
(global-set-key (kbd "C-l") 'windmove-right)

However in org-mode...

C-k runs the command org-kill-line, which is an interactive Lisp function in `org.el'.

It is bound to C-k.

(org-kill-line &optional ARG)

Kill line, to tags or end of line.

So I tried removing the org-kill-line mapping but I couldn't get it to work:

(eval-after-load "org"
   '(define-key org-mode-map [remap org-kill-line] nil))

Disclaimer: I've only been using emacs for 3 days so far.

1
  • Consider using the "sharp quote" (#') instead of just "quote" (') when quoting functions (including commands, which are just interactive functions). Feb 12, 2016 at 1:49

1 Answer 1

9

Org-mode is built-in to Emacs 24.5.1, so there's no need to eval-after-load. with-eval-after-load is also preferred over eval-after-load.

Instead of trying to remap org-kill-line, why not just specify C-k?

(define-key org-mode-map (kbd "C-k") nil)

Also, there may be other modes that bind a common key like C-k. Instead, you can use C-c k. The C-(letter) keys, by convention, are reserved for user-specified bindings.

2
  • That did the trick! Thanks @tianxiang-xiong
    – Tom
    Feb 12, 2016 at 1:41
  • I believe this answer is partially incorrect. While org-mode is distributed with Emacs, it is not loaded by default, so you do need with-eval-after-load to avoid potentially referencing org-mode-map before it is defined. However, unbinding C-k is correct.
    – Dale
    Feb 11, 2020 at 21:40

Your Answer

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

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