vscode-markdown icon indicating copy to clipboard operation
vscode-markdown copied to clipboard

Increase and decrease heading levels in selected text

Open garyking opened this issue 5 years ago • 8 comments

When selecting some text with headings, please make it possible to increase and decrease heading levels within the selection.

For instance, if the following text is selected:

# abc

def

And then the command Increase heading levels is run, then it should result as:

## abc

def

garyking avatar May 01 '19 02:05 garyking

Have you tried ctrl + shift + ]?

yzhang-gh avatar May 01 '19 09:05 yzhang-gh

Have you tried ctrl + shift + ]?

That just increases the heading level on the last line in the selected text, not all headings. And it converts regular text to a heading, when I don't think it should.

garyking avatar May 01 '19 15:05 garyking

Actually, it is designed to increase/decrease the heading level under cursor (not selection).

yzhang-gh avatar May 01 '19 20:05 yzhang-gh

bump

ksdavidc avatar Jun 23 '21 19:06 ksdavidc

Actually, it is designed to increase/decrease the heading level under cursor (not selection).

It being designed that way is the issue. VSCode generally applies modifications like this to all lines selected, whether that is through multi-line selection or through multi-cursor selection. This particular shortcut only applies it to the beginning of whatever the first line of the selection is, which severely limits the utility of the shortcut since you might as well just type in the characters rather than use the shortcut.

Dartis4 avatar Jan 28 '22 19:01 Dartis4

Thanks for the feedback. I agree it would be better to be selection-aware.

yzhang-gh avatar Jan 29 '22 11:01 yzhang-gh

Hello! I would upvote this feature. While writing long notes or research articles – especially when there are lots of edit to do (like moving of sections within a file) – this feature becomes indispensable.

werunom avatar Jul 31 '23 14:07 werunom

Thanks for all the feedback. However, I may not have enough time to do this (especially test it).

In case there is someone interested, it can be easily changed to iterate over the lineIndex in selection (line 55) rather than selection.active.line.

https://github.com/yzhang-gh/vscode-markdown/blob/83f602638bf96f5249e3b9856baf9f31b933fad1/src/formatting.ts#L53-L66

yzhang-gh avatar Aug 05 '23 02:08 yzhang-gh