Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
alexander-novo opened this issue Jun 13, 2018 · 5 comments

Comments

@alexander-novo
Copy link

alexander-novo commented Jun 13, 2018

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
Copy link
Collaborator

note that there was also a feature request for this here previously, but the author closed it with no explanation why #1722

@sinkap
Copy link

sinkap commented Aug 30, 2019

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

@deathaxe
Copy link
Collaborator

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
Copy link

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
Copy link
Collaborator

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants