Org-roam-extract subtree, but in reverse?

With org-roam-extract-subtree, I can convert in-file nodes into separate file nodes. I’ve been using this command a lot, because I often write too much into a single file. However, I sometimes create nodes that make me think: “This text would fit better if it was in the same node as that one.” Is there a command for that, or should there be some Elisp stuff I have to devise in order to make this work?

You are free to pursue your own workflow.

For me, I find it easy and flexible to use a simple manual “cut-and-paste” procedure like this below for a case you describe:

  1. Move the cursor to the beginning of the subtree
  2. Fold it with TAB
  3. kill-line with C-k (this puts the whole subtree into the kill ring and remove it from the current buffer)
  4. Move to the other note and place the cursor where I want to paste the subtree
  5. yank it with C-y (I always have CUA-mode on, so C-v also works).
1 Like

This works. :grin: :+1: my only other concern is what if the node is a singular file? Meaning, no subtrees, and the file itself is the node? Will killing and yanking the properties drawer, title, and the entire body of text work?

Sure. I don’t see any problems. Slightly different operations.
You can try and see what happens. Nothing will get lost anyway.

If your ID needs to be the same, I’d probably first kill it from the original file and save, so that the database won’t have the ID any longer. And then create a headline node and paste the ID and “move” it to the new file (as a headline node).

If you are OK with just adding a new ID, you can just manually add a new ID property to the new headline.

I’d also trash the original file.

If you know that you will be doing this many times, then consider always creating a node as a headline even if there is only one in a file (so no file-node, but always headline-nodes). Then you don’t have to do any special treatment – all your nodes will be easy to move around.