7

With this tree structure:

* A
** A.1
** A.2
** A.3
a3a3a3a3a3a3a3
* B
* C
** C.1
*** C.1.1
*** C.1.2
*** C.1.3
** C.2
** C.3

… I can move C.1 (with its children) up and down with M-↑ and M-↓. Easy.

If I use M-S-↑ and M-S-↓, only the C.1 node is moved, without its children. Easy, too, however the Manual claims in http://orgmode.org/manual/Structure-editing.html:

M-S-<up> (org-move-subtree-up)

Move subtree up (swap with previous subtree of same level).

M-S-<down> (org-move-subtree-down)

Move subtree down (swap with next subtree of same level).

… so, really, it should be the other way round. Nevermind, though.

Also, using M-S-↑↓, the C.1 node can be moved out of its parent, C. When this happens, the C.1 node always keeps its level (** in this case), no matter where it ends up.

Now, what I want to achieve is to move the whole C.1 subtree, the whole branch with all the children, similarly, out of C, while keeping its ** level.

This could be done with org-refile or killing the subtree C-c C-x C-w and yanking it at some new point, however, nothing beats the experience (especially when I’ve got to move hundreds of such trees after importing my notes from Wunderlist).

Using GNU Emacs 25.0.50.1 and Org-mode version 8.3.2 (8.3.2-10-g00dacd-elpa).

3
  • how do you import notes from wunderlist? thanks!
    – netawater
    Nov 8, 2015 at 15:02
  • @netawater, I did import them using my script, github.com/michalrus/org-import-wunderlist . If you want to synchronize it regularly, use org-wunderlist, but that doesn’t work well for me.
    – Michal Rus
    Nov 8, 2015 at 20:48
  • avy-org-refile-child
    – HappyFace
    Mar 26, 2021 at 8:31

2 Answers 2

3

Try This

Using arrow keys to edit a nested tree structure can be confusing but is worth learning.

  1. Place the cursor on C.1 line.

    Note: The cursor will remain on C.1 line unless otherwise noted.

    * A
    ** A.1
    ** A.2
    ** A.3
    a3a3a3a3a3a3a3
    * B
    * C
    ** C.1
    *** C.1.1
    *** C.1.2
    *** C.1.3
    ** C.2
    ** C.3
    
  2. Move C.1 down to bottom of C with by typing M-↓ repeatedly to preserve C.2 and C.3 branches.

    Outline should look like:

    * A
    ** A.1
    ** A.2
    ** A.3
    a3a3a3a3a3a3a3
    * B
    * C
    ** C.2
    ** C.3
    ** C.1
    *** C.1.1
    *** C.1.2
    *** C.1.3
    
  3. Outdent entire C.1 subtree by typing M-S-←.

    Outline should look like:

    * A
    ** A.1
    ** A.2
    ** A.3
    a3a3a3a3a3a3a3
    * B
    * C
    ** C.2
    ** C.3
    * C.1
    ** C.1.1
    ** C.1.2
    ** C.1.3
    
  4. Move C.1 subtree above C subtree by typing M-↑

    Outline should look like:

    * A
    ** A.1
    ** A.2
    ** A.3
    a3a3a3a3a3a3a3
    * B
    * C.1
    ** C.1.1
    ** C.1.2
    ** C.1.3
    * C
    ** C.2
    ** C.3
    
  5. Indent C.1 subtree under another subtree, e.g. B, by typing M-S-→

    Outline should look like:

    * A
    ** A.1
    ** A.2
    ** A.3
    a3a3a3a3a3a3a3
    * B
    ** C.1
    *** C.1.1
    *** C.1.2
    *** C.1.3
    * C
    ** C.2
    ** C.3
    

I'll add some additional tips and examples to my answer soon.

Tested using

GNU Emacs 24.4.1 (x86_64-apple-darwin14.0.0, NS apple-appkit-1343.14)

org-version: 8.3.1

2
  • A bit weird, but, I guess, it's the only way. Thanks! I don't know, however, why M-S-↓↑ won't move the whole subtree. It would be really convenient.
    – Michal Rus
    Oct 20, 2015 at 15:38
  • @MichalRus, agreed, because C-x C-t (transpose-lines) already does what M-S-<up>/<down> does.
    – Geoffrey
    May 9, 2017 at 15:16
1

I used org-cut-subtree and org-yank to accomplish this.

GNU Emacs 27.1 Org mode version 9.3

3
  • Alternatively, fold the subtree with TAB, then C-k C-k, C-y at new place, then unfold.
    – NickD
    Nov 29, 2021 at 3:19
  • Tried this, and it seems to work correctly with normal org-mode. But with org-indent-mode turned on, this does not work properly. It yanks somewhere in the middle of the headings. I always have org-indent-mode on, so it is tricky to use this. @NickD Dec 1, 2021 at 15:02
  • I use org-indent-mode too and I've never had any trouble like that.
    – NickD
    Dec 1, 2021 at 15:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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