Last active
November 1, 2018 06:38
-
-
Save alexozer/3ed6f09fadf55423ac0d8931b86715e2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun ozer/new-org-heading (default-enter) | |
(if (org-at-heading-p) | |
;; Enter once will make new heading, twice will clear | |
(if (eq (org-entry-get nil "ITEM") "") | |
(evil-change (line-beginning-position) (line-end-position)) | |
;; Insert a new TODO if we're on a TODO | |
(if (org-get-todo-state) | |
(org-insert-todo-heading-respect-content) | |
(org-insert-heading-respect-content) | |
) | |
(evil-append 1) | |
) | |
;; Do whatever enter normally does | |
(funcall default-enter) | |
) | |
) | |
(evil-define-key 'normal org-mode-map | |
(kbd "RET") (lambda () (interactive) (ozer/new-org-heading 'org-open-at-point)) | |
) | |
(evil-define-key 'insert org-mode-map | |
(kbd "RET") (lambda () (interactive) (ozer/new-org-heading 'org-return)) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This makes creating heading pretty easy for someone who doesn't like to press ctrl like me and wants something more closely resembling the ease of bulleted outlines in word processors.
Pressing Enter (in normal or insert mode) while on a heading will insert a new one below. If Enter is pressed again, it will be equivalent to having pressed Enter once with default behavior. If Enter is pressed on a heading with a TODO status, a new TODO heading will be created.
The other org functionality of Enter is left intact (opening links, new table rows, etc).