-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Roslyn formatter should offer an option to enforce a maximum number of columns per line #47158
Comments
Note that the use of tabs for indentation and spaces for alignment is not currently supported by the Roslyn formatter, but is covered by #24031 (comment). |
related to #15406 and dotnet/format#246 |
Duplicate of #15406 |
For me, there is no need to modify single tokens/literals. If a single token + indentation exceeds the column limit, I would expect the formatter to break after that token. The only exception would be semicolons, these should be kept on the same line as the last token. I like your proposal a lot. Thank you! |
One feature I am missing in Visual Studio is being able to automatically enforce a maximum line length. That is, if a line of code is too long, it automatically gets broken up into multiple lines. I often find myself writing very long lines of code (up to 200 columns). However, I don't want to have to think about arranging and breaking up the code. This bad habit is enforced through very large monitors.
TL/DR: Please add support similar to clang-format options like
ColumnLimit
and theAlign*
andBreakBefore*
group of options. (see https://clang.llvm.org/docs/ClangFormatStyleOptions.html)The reason I don't want to use clang-format is because it does not support all C# language features (for example LINQ clauses are not arranged nicely).
Example 1)
Parameter lists/declarations should automatically be split into multiple lines and indented/aligned properly.
Before clang-format:
![image](https://user-images.githubusercontent.com/344204/91343464-e4764900-e7dc-11ea-9d0b-5ae859523503.png)
After clang-format:
![image](https://user-images.githubusercontent.com/344204/91343501-efc97480-e7dc-11ea-9278-23e0bd14cc75.png)
Example 2)
Expressions, conditions and comments should be split into multiple lines and indented/aligned properly.
Before clang-format:
![image](https://user-images.githubusercontent.com/344204/91344118-cbba6300-e7dd-11ea-8a0c-a10b138aedc4.png)
After clang-format:
![image](https://user-images.githubusercontent.com/344204/91344266-03c1a600-e7de-11ea-99db-0cb4f420cbd7.png)
The text was updated successfully, but these errors were encountered: