I am using spacemacs which contains org-mode and evil. Whenever I insert a heading (either org-insert-heading, org-insert-heading-after-current or org-insert-subheading), I have to do two extra actions: move cursor to the end of line, change to insert mode to start typing. How do I get these two actions done automatically for all the insert heading functions?

What I am thinking now is to write wraper functions for these functions, and then redefine the shortcut keys. But wouldn't there be a better way?

3 Answers 3


You need to set org-M-RET-may-split-line to nil via:

(setq org-M-RET-may-split-line nil) in your .spacemacs or .emacs file.

look at the documentation for org-insert-heading with SPC h d f in spacemacs or C-h f in emacs. Setting that variable to nil will tell org to never split the line on an insert.


The following function should meet your goal:

(defun my-insert-new-sibling-after-current (&optional force-heading)
 (if force-heading ; is set to t
         ((org-on-heading-p) (org-insert-heading-after-current))
         (t                  (progn 
                                (org-speed-move-safe (quote outline-previous-visible-heading))
                                (org-insert-heading-respect-content nil))))
         ((org-on-heading-p) (org-insert-heading-after-current))
         ((org-at-item-p)    (org-meta-return))
         (t                  (org-return))))
 (evil-append nil))

As pointed to in this answer, setting evil-move-beyond-eol to non-nil, although not very vimesque, would allow you to move pass the last character, fixing the unwanted behavior you're having.

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.