8

Given an outline with arbitrary structure, how can one demote every single heading by one?

For example, starting from something like this

* Lorem ips
  um dolor sit ame
** t, consectetur a
   dipiscing elit. Vivamus ph
*** aretra diam lorem, e
** u consectetur urna m
   - alesuada sit amet. Donec turpis lacus, molestie id nunc et, laoreet
   - cursus ex Integer porttitor nisl neque, id f ermentum erat tincidun
   - t sit amet. Etiam in d
*** ignissim quam. D
* onec non 

...what's the easiest way to get to this:

** Lorem ips
   um dolor sit ame
*** t, consectetur a
    dipiscing elit. Vivamus ph
**** aretra diam lorem, e
*** u consectetur urna m
    - alesuada sit amet. Donec turpis lacus, molestie id nunc et, laoreet
    - cursus ex Integer porttitor nisl neque, id f ermentum erat tincidun
    - t sit amet. Etiam in d
**** ignissim quam. D
** onec non 

Of course, after this global demotion I'd add a new top-level header encompassing all the demoted headers in its subtree.

3
  • @lawlist I think you mean selecting all and pressing alt-right-arrow. (This addresses a deleted comment.)
    – Tobias
    Jan 3 '16 at 0:01
  • @Tobias -- I was thinking of meta-shift-arrow (instead of shift-arrow) with a selected region, but my preliminary test after I posted a comment showed it only affected a portion of the original poster's test code, so I deleted the comment . . . [I understood the question to mean everything in one fell swoop, and my initial idea only affected the first main heading and every sub-heading underneath, but not subsequent main headings and subtrees.]
    – lawlist
    Jan 3 '16 at 0:19
  • 1
    @lawlist alt-right-arrow does that.
    – Tobias
    Jan 3 '16 at 8:01
15

org-do-demote will demote everything within a marked region. According to the docstring:

(org-do-demote)

Demote the current heading lower down the tree. If the region is active in transient-mark-mode, demote all headings in the region.

So: mark the region and org-do-demote. In practice, you can use org-mataright in this situation, which will demote the subtree.

Alternately, you can simply use org-demote-subtree:

org-demote-subtree is an interactive compiled Lisp function in org.el.

(org-demote-subtree)

Demote the entire subtree. See org-do-demote. See also org-do-promote.

org-demote-subtree is bound to M-S-<right>.

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.