Extract or Preserve Only the Headings (Especially Headings of Different Levels) From a Note For Editing

Use case or problem

It would be useful to have a way to extract, or preserve, only the headings of any particular note, to allow for copying and editing as a new or substitute note.

For instance, if a note has different headings, established at different levels (such as h1, h2, h3, h4), as a user, one should be able to extract, or keep, just the headings of such a file.

Proposed solution

This feature can be implemented by allowing users to FOLD the contents of headings at DIFFERENT HEADING LEVELS by relying on a command or hitting a hotkey.

This new feature would allow users to go beyond FOLDING ALL, including subheadings, like h2, h3, and h4, UNDER THE HIGHEST HEADING LEVEL, such as h1.

Another possibility is the fact that, after making a copy of a given document, there could be a command or hotkey to DELETE any content that is subsumed or included under headings of different levels (h1 and h3).

In other words, if one were to have headings of different levels with bullet-pointed sentences, images, and/or paragraphs (without bullets or numbering), it should be possible to DELETE any and all contents under those headings, for the sake of getting an editable outline.

In turn, this would LEAVE INTACT ALL HEADINGS AT DIFFERENT LEVELS.

This feature would allow users to have a list of all of differently-leveled headings, to get a better idea of the contents of a note.

As of now, there is only a way TO GET AN IDEA OF all of the headings of any particular note --through only VIEWING a note’s outline or table of contents.

However, USERS CANNOT COPY AND/OR EDIT such an outline or table of contents.

Related feature requests

*(The caps, presented with kindness in the above writing/text, are there only for gentle emphasis).

1 Like

You can do that with a template with all the headers, etc set up, but nothing else. The you can open that template and fill in what you need.

I like this idea. Doing this with templates is a good workaround in some workflows that are more predictable, but would be limiting.

I often wish that I could fold the various headings of a note and just select the result, use a special hotkey to copy just the headings, and then be able to paste them elsewhere (perhaps into a template).

Another implementation would be to use the Outline pane, then individually select the headings or range you want to extract, and finally press the hotkey to paste the extracted empty heading structure (of course with names).

This would be very useful. Good idea!

Thanks!

1 Like

Individual selection of headings would take a lot of time and would defeat the purpose, in some cases.

This point from you illustrates exactly what I would like to do as well.

I often wish that I could fold the various headings of a note and just select the result, use a special hotkey to copy just the headings, and then be able to paste them elsewhere (perhaps into a template).

There is potentially a way to do what you’d like to do with regex, though I cannot confirm that it works.

See the post below.

1 Like

It has been a while since OP but I wanted to contribute my method for extracting all headings from a note.

This regex query does what you want for any “note title” in your vault.

path:"note title" /(^#+\s.*)/

Unfortunately, it’s impossible to copy search results from Obsidian queries because their query copy feature is incomplete or broken.

So I just use this website

  1. https://regexr.com/
  2. use this expression (^#+\s.*)
  3. make sure the /gm flags are selected (global and multiline)
  4. Paste your full note into the Text Section
  5. In the Tools section select the List tab
  6. Copy the filtered set consisting of only your headers

Done

1 Like