sublimehq / sublime_text

Issue tracker for Sublime Text
https://www.sublimetext.com
804 stars 39 forks source link

Option to disable differences in word wrap indentation for text languages and source languages #2356

Open alexander-novo opened 6 years ago

alexander-novo commented 6 years ago

According to this Stack Overflow question, the decision to add an extra indentation after word wrapping with indent_subsequent_lines set to true is based solely on whether the language has been set to a "text"/markup or "source"/code language. This makes sense for straight plaintext, but many markup languages heavily rely on indentation to make them legible.

Consider this LaTeX file for a second: image This align environment contains 6 aligned lines of mathematical formulas (aligned at the &), but lines 106 and 107 wrap due to their length. The resulting 'extra' lines look like they are additional lines that are misaligned, as they do not begin with &.

The Stack Overflow question suggests the best solution to the problem being to change the syntax file of the language to a code-based language, but also mentions that this breaks other things such as hotkeys and other formatting. It would be nice if there were a syntax specific setting that would allow an override to force an extra indent for markup languages or no indent for code languages.

keith-hall commented 6 years ago

note that there was also a feature request for this here previously, but the author closed it with no explanation why https://github.com/SublimeTextIssues/Core/issues/1722

sinkap commented 5 years ago

I am facing this as well today, was this ever resolved? and is this documented somewhere?

deathaxe commented 4 years ago

A dedicated hangingIndentPattern may be the most flexible solution to specify language specific rules for hanging indentions. The pattern could be matched against the beginning of a line to determine the indention level of each subsequent line. The indention would then consist of the indention level of that line + the length of the first capture group.

<key>hangingIndentPattern</key>
<string><![CDATA[(?x)
    ( (?: - | * | \d+[.:)]? | ^#+ ) \s+ )(?=\w+)
]]></string>
pineapplemachine commented 2 years ago

Curiously, there is an option to set indent_subsequent_lines in syntax settings for a given language. When setting this to false for code, the subsequent lines are unindented completely...and then indented once more, due to the unconfigurable hanging indent.

It would be very helpful if at least this setting could have three different options: Don't indent, indent to same, and hanging indent. I'm surprised that this seems to have remained unresolved for so long.

deathaxe commented 1 year ago

Btw., indent_subsequent_lines: false doesn't have effect if a line starts at bol.