0

I often cut and paste folded top-level headings (only the heading is displayed, not its subcontent and tree).

When I do a paste, the heading is pasted unfolded - ie all subcontent and the tree is shown. After the paste, the current cursor point is at the bottom of the subcontent.

If I have eg 200 lines of subcontent, then I have to scroll back up to the heading to fold it.

Is there a setting in org mode to paste a heading and subcontent but not expand/unfold the subcontent?

Thanks ahead of time for any help......

2
  • You can navigate by heading: C-c C-p will take you to the previous heading. If the paste involved just a single heading, that's all that's needed. If there are more, you will need to do C-c C-p a few times to get there, but it's generally fast. The answer provides a few more generally applicable methods that are worth remembering, particularly the first one. – NickD Nov 8 '20 at 21:18
  • Thanks once again NickD for your input. This seems like a convenient way to do what I would like to do. – ironfish Nov 9 '20 at 13:55
1

Using Emacs functionality, you could either: 1) call yank with an argument, C-u C-y, that will leave point at the beginning of the yanked text; 2) call yank and then pop the mark, C-y C-u C-SPC, that would bring point back to the beginning of the yanked text after yanking.

Using Org functionality, you could use its specialized commands for the purpose: org-cut-special (bound by default to C-c C-x C-w) and org-paste-special (bound by default to C-c C-x C-y). This should carry around the folded state of your subtrees. Note that org-paste-special may promote/demote the yanked subtree, according to context. If that's not wanted, regular org-yank (C-y) should also deliver it folded, if it was killed as a subtree (that is, with C-c C-x C-w) to start with.

8
  • Thank you gusbrs for your input. I am not familiar with the terminology such as yank and killed, and so I will have to learn that (which I am happy to do) to understand your response. – ironfish Nov 9 '20 at 13:54
  • 1
    "Yank" in emacs means the same thing as "paste" does in GUI environments. The function yank is bound to C-y by default. C-u is the "universal prefix argument": it basically calls the next function with a special argument that the function can interpret as it wants. So 1) in the answer says: if you press C-y alone, you yank ("paste") the text and that leaves you with the cursor at the end of the yanked text. But if you do the yank with the prefix argument (C-u C-y) then you are left with the cursor at the beginning of the yanked text. – NickD Nov 9 '20 at 14:38
  • 1
    Do C-h f yank RET to see the doc string of the function which describes this. See Killing and Moving Text in the Emacs manual for all the gory details. – NickD Nov 9 '20 at 14:40
  • @NickD Thanks for clearing things for the OP. I presumed "emacs-lingo", and perhaps I shouldn't have. – gusbrs Nov 9 '20 at 15:10
  • It's impossible to know, so we do the best that we can. – NickD Nov 9 '20 at 18:13

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.