0

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?

1

The following function should meet your goal:

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

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, privacy policy and cookie policy

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