What I'm trying to do is have C-a and C-e take me to the beginning or ending, respectively, of the logical line, not the visual line, in org-mode (with visual-line-mode active). I see that C-a is mapped to org-beginning-of-line, which, like a lot of org-mode things, seems to be context-dependent.
Here's what I'm trying.
(define-key org-mode-map (kbd "C-a") 'move-beginning-of-line)
(define-key org-mode-map (kbd "C-a") 'move-end-of-line)
This seems to do nothing. C-h k
followed by C-a
still shows it's still mapped to org-beginning-of-line. I also tried using the angle bracket form of calling kbd: (kbd "<C-a>")
, which made no difference.
If it helps, here's what I get when I do C-h m
:
Enabled minor modes: Auto-Composition Auto-Compression Auto-Encryption
Blink-Cursor Electric-Indent File-Name-Shadow Font-Lock Global-Eldoc
Global-Font-Lock Global-Visual-Line Line-Number Mac-Mouse-Wheel
Menu-Bar Show-Paren Tool-Bar Tooltip Transient-Mark Visual-Line
UPDATE: both @Tyler and @NickD solved the problem with their answers. Also it turns out the visual-line-mode-map had a remapping as well, which also needed to be unmapped. Here's specifically what I added to my .emacs file to solve the entire thing:
(add-hook 'visual-line-mode-hook
(lambda ()
(define-key visual-line-mode-map [remap move-beginning-of-line] nil)
(define-key visual-line-mode-map (kbd "C-a") 'move-beginning-of-line)
(define-key visual-line-mode-map [remap move-end-of-line] nil)
(define-key visual-line-mode-map (kbd "C-e") 'move-end-of-line)))
(add-hook 'org-mode-hook
(lambda ()
(define-key org-mode-map [remap move-beginning-of-line] nil)
(define-key org-mode-map (kbd "C-a") 'move-beginning-of-line)
(define-key org-mode-map [remap move-end-of-line] nil)
(define-key org-mode-map (kbd "C-e") 'move-end-of-line)))