You are probably looking for C-u M-RET
which calls org-insert-heading
with a prefix argument. The doc string for org-insert-heading
says:
With a ‘C-u’ prefix, set ‘org-insert-heading-respect-content’ to
a non-nil value for the duration of the command. This forces the
insertion of a heading after the current subtree, independently
on the location of point.
So if you are in the first-level subtree, it will go to the end of the subtree and insert a first-level heading, but if you are in a second-level subtree, it will go to the end of that and insert a second-level heading. In this second case, there is no way to guess that you want a first level heading, so you'll have to adjust the level with M-<left>
or M-<right>
as I mentioned in the comment.
If you really want a first-level heading at the end of the current subtree, you can define a function and bind it to a key (but IMO, that's a waste):
(defun ndk/org-insert-top-level-heading-at-end-of-current-subtree ()
(interactive)
(org-insert-heading '(4) nil t))
(define-key 'org-mode-map (kbd "S-<f12>") #'ndk/org-insert-top-level-heading-at-end-of-current-subtree)
The '(4)
makes org-insert-heading
behave the same way that it would if it were called interactively with a C-u
prefix and the t
forces it to insert a first-level headline instead of what it normally would. I bound it to S-<f12>
because that is likely unused but you can suit yourself.
C-n
or<right>...<right>
(as many as required to move you to after the ellipsis - you can useC-f
instead of<right>
if you prefer) - and then pressM-RET
. – NickD Oct 26 '20 at 17:26**
instead of what I would like:*
. Any way to change to same level heading behaviour? – herophant Oct 26 '20 at 19:24Heading 2
? What I do is insert a heading and then adjust the level withM-<left>
orM-<right>
, although there are probably slicker methods: my trouble is that the only way I can remember these things is if they are baked into my muscle memory and that'sM-RET
andM-<left>
- anything else might as well not exist :-) But tryC-u M-RET
. – NickD Oct 26 '20 at 19:32