Note #2026-03-18-001
A small #Emacs #OrgMode quality-of-life tweak. I often need to replace an org heading's title while preserving the original text in the body. The problem is that pressing enter on a heading inserts a line above the properties drawer, which breaks things.
Here's function that moves the heading title into the body (below the properties drawer and metadata), and binds it to S-RET:
(defun my-org-demote-title-to-body ()
"Move the current heading's title into the body, below the metadata.
Point returns to the heading for editing."
(interactive)
(org-back-to-heading t)
(let* ((element (org-element-at-point))
(title (org-element-property :raw-value element)))
(org-edit-headline "")
(save-excursion
(org-end-of-meta-data t)
(insert title "\n"))
(org-beginning-of-line)))
(defun my-org-shift-return ()
"On a heading, demote title to body. In a table, copy down."
(interactive)
(cond
((org-at-heading-p) (my-org-demote-title-to-body))
((org-at-table-p) (org-table-copy-down 1))
(t (org-return))))
(define-key org-mode-map (kbd "S-<return>") #'my-org-shift-return)
Interactions
π 1 like