Extract Note / Refactor

Several times now I’ve been cleaning up notes and thought that a way to extract text into a new note could be a time saver. Similar to refactoring code in an IDE, you would select a block of text, then select from the right click menu (or press a hotkey), which opens up a prompt for a new note title. This should probably allow searching for existing titles, so you don’t have duplicates.

After pressing enter, the new note is created, and a link is inserted in the place of the text in the original note.

Another idea might be if you tried extracting the text to an existing note, it could append it to the end of that note, effective just moving that text between notes.

52 Likes

Feature to create a new note from a selection and create a link to it from the original note. If just a few words are selected, this becomes the title of the new note and the body is left blank. If more than one paragraph is selected, the first sentence / paragraph becomes the title of the new note and the rest is the body.

6 Likes

Agree, as I do this frequently, mostly when pulling something from my daily notes. Although, I’d rather embed the new note instead of linking it.

I guess this is also related to Block references. This way you could manually split your notes into smaller pieces and reference the new “blocks” as needed.

6 Likes

Sounds like we both came to almost the same idea independently - Extract Note / Refactor . I hope that’s a sign others would think it would be useful!

1 Like

Apologies @BlueSun, I didn’t see that one before posting…

Oh, no worries, I hope I didn’t come off as accusatory. I don’t care who gets credit for the idea, I’d just love to see it implemented!

Merged, hope you guys don’t mind @BlueSun @GBC.

3 Likes

Would also love to see this. My imported notes are a vast mess and I’d like to make them more manageable/navigable

This would be a really cool feature that I would love.

For my most common use case, it would be handy to have the option to be able to replace the extracted text with a transclusion/embed ![[ ]] instead of a link [[ ]]… this could either be with two separate hotkeys/right-click options, or just a single ‘extract into new note’ option whose function can be modified in settings.

2 Likes

This is such a crucial feature for me that I switched to using the VS Code extensions Foam and Markdown Memo for refactoring my notes. I made a somewhat clunky macro to Extract Note, but it works well enough. You can work off of the same Obsidian vault folder (generally) without any issues.

You can see the details here: https://github.com/nixsee/NewNoteFromSelection-VSCode

Given the local graph feature that was just implemented in Obsidian, once I get my notes refactored, I’ll be moving my workflow back to Obsidian until Foam is able to make progress (it’s still in very alpha stages) and I’ll reassess then. Clearly this shows how important plain Markdown notes are!

2 Likes

I agree this would be useful, right now I just do it manually albeit with some string replacement for quickly formatting the new page. It would be nice to just be able to select text and press a hotkey that creates a new page with the selected text and embeds/links it in the original page. The good thing is that even if it doesn’t get implemented, it won’t be difficult to do with the api.

1 Like

Adding my +1 to this feature.

I do this often with my daily notes:

  • I have a thought/idea that comes up.
  • I create a title “###### Name of Idea”, and I start writing my idea underneath this title.
  • Quickly enough, I realize this idea has different components/is related to different concept and deserves it’s own note.
  • So I change the paragraph beneath the title to ![[Name of the idea]], click on it to create a new file, and then just paste my text there.
    (I also do the opposite sometimes: create a note and embed with the title from my daily note like this: ![[2020-08-14#Name of the idea]] )

A hotkey after selection that implements what has been discussed in this thread would be a nice Quality of Life improvement.

However, I do think this will be much easier to implement or become natural once a WYSIWYG editor is implemented, which will spare us switching from edit to preview mode.

1 Like

+1 This sounds great.

One usecase I’ve always had in mind with this was just taking a section (everything under a heading and its subheadings) and simply refactoring that out.

This way you could trivially refactor all links pointing to that section or one of its subsections. If a note is structured enough, but too long overall, it would simplify things.

2 Likes

Another +1 to this feature. I’m a student and when I’m taking notes while watching lectures or reading I don’t want to worry about note structure, so I usually just make big note sections and organize them into discrete notes later. A feature like this would really improve this experience.

2 Likes

My main aim to refactor note is to preserve links.

So if I have a bigger note with more concepts in it, and finally extract those to their own file, I’d like to have all the links remain valid.

2 Likes

As usual, here a code snippet which will add this feature while it doesn’t exist inside of Obsidian. Highly experimental, be careful.

1 Like

I think a lot of map of content users might like this feature, since maps/workspace notes often start as large dumps of thoughts that hopefully ‘bud’ off into their own notes.

Bonus: leave behind an [[untitled]] link in the existing note so that it automatically updates when I rename the new note (stop my mouth is watering)

Edit: thank you to the mod that moved my other thread here. I did not know this was called “refactoring” Would love to see this feature

1 Like

There is now a community plugin that does all of this!

1 Like

I have finally determined why I am not writing in Obsidian as much as I like. And an added feature to the note refactor ext may be all that’s needed!

Do to issues with working memory and processing speed I see the ability to automatically create backlinks absoluty neccessariy in reducing cognative load. This is where the note-refractor plugin can help.

If I was able to refactor the selected text to a new note while keeping while keeping the original note in its place, this is what would help greatly. So that I can see the note in it’s original context.

2 Likes

Use case or problem

While it is wise to not create notes automatically through backlinks, there are various cases where this is suboptimal behaviour.

For instance, while writing cross-referenced wikis. In these cases, users will have to copy-paste text to the new note manually; this gets cumbersome.

Proposed solution

It is not a good idea to automatically create notes for each backlink. However, when a backlink is referenced in a header, like
## [[Backlink]]

The content of the document from that point until the next header of the same level can be copied to a new note, and this note can be automatically created.

Current workaround (optional)

None that I can think of.

Related feature requests (optional)

Create this feature as a toggle, so that users who don’t want this behaviour can keep using Obsidian like they now do.

1 Like