Skip to content

Add extra hanging indentation after a word-wrap to account for lists #5737

Open
@eugenesvk

Description

Problem description

(for example) In markdown it's common to have lists that can span multiple lines. Soft-wrapping allows you to still see the overflowing text. However, soft-wrapping doesn't account for the width of the list markers (for example, 11. or 12. for a numbered list below), so it looks a bit more ugly then necessary

11. list with a long line...
...continued currently from the beginning of a line, not the beginning of the text
12. next item
↑ wrong   soft-wrap without hanging indentation accounting for the width of the list indicator
↓ correct soft-wrap with        ↑...↑
11. list with a long line...
    ...continued with a hanging indent, whose width equals to the width of `11.`
12. next item, note the nice text alignment

Preferred solution

Ideally there should be a flexible API that would allow the user/plugin/syntax author to set a combination of

  • a regex
    e.g. ^\s*\d*\. to match 11. and 12.
    (similar to formatlistpat in vim)
  • hanging indent width (fixed number or the width of the starting regex matching group number/name e.g., -1 to set the width to =1. for the single digit list items and =11. for the double digit list items
    (similar to breakindentopt in vim)
  • a list of syntax scopes
    e.g. text.html.markdown markup.list.numbered.markdown meta.paragraph.list.markdown -markup.raw.code-fence.markdown-gfm (last one excludes fenced code from this)
    (doesn't exist in vim)

I think this should allow enough flexibility to cover most use cases(hopefully?) So you could change hanging indents in regular text vs embedded source code in markdown vs non-embedded source code etc.

Alternatives

As far as I understand, plugins can't do that, so no good alternatives exist (hard-wrapping is awful, so not an alternative)

Additional Information

This was mentioned in multiple places, at least in this package SublimeText-Markdown/MarkdownEditing#42
As far as I understand it, there are still no Sublime Text Core APIs that would allow even plugin authors to achieve this

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions