Is there a way to change many headings by one level at the same time?

When I start a note I write my headings starting with level 1, 2, etc but sometimes I find myself wanting to augment the scope of the note and needing to move a whole section “down” in levels.

A solution would be to search replace the # and add another # but that necesarily applies to all of the text which may be even worse on large enough files. It also applies to any hash in the text that could be unrelated to a heading.

Even selecting all the headings with alt is far from optimal because you need to give the new level each time starting from the lowest level (or you lose all logic in your headings). This can get really tedious.

I also tried to move the headings via the outline but you can only move them and not change their level…

I’m out of solutions but since we have some options related to headings (set, toogle, fold, unfold, bookmark, remove,…) I thought that maybe there was a way? If that’s not the case, maybe I’ll move this towards feature requests…

A workaround method to better anchor what needs changing would be to use regular expressions.
Install the Apply Patterns plugin and create a new pattern with this single rule:
Matching text: (^#{1,5})(\s)
Replacement text: #$1$2
Make sure you add global and multiline flags to the rule.

Then, while still in Apply Patterns settings modal, add this pattern as a command. You can apply for whole document or for selection method, for which you would need to select text beforehand – handy if you want to increase levels on particular sublevels only. Then you can bind a keyboard shortcut to (either of) these in Hotkeys.

What this ultimately does is increases the heading level by one without affecting inline tags.
If you effected a change by mistake, you can CTRL+Z to Undo.

perhaps …

I have not tried it myself yet.

1 Like

It seems like it, thanks! I’ll try it but I’m not sure how I feel about adding one more plugin… I’ll see how often I use it

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.