Wrapping
- 2 minutes to read
The Wrapping options page provides settings for the following code elements’ wrapping rules:
- LINQ Expression
- Arithmetic Expression
- Relational Expression
- Bitwise Expression
- Logical Expression
- Ternary Expression
- Assignment Expression
- Arguments
- Parameters
- Array Initializer
- Collection Initializer
- Object Initializer
- Chained Method Calls
- Lambda Expression
- Expression Body
- Type Parameters
- Null Coalescing Expression
- Base List
- Constructor Initializer
Each element of these expressions has configuration options. You can set the following wrapping options:
How CodeRush should wrap expression elements:
- No wrap - does not add extra line breaks. This option leaves existing line breaks if the Keep existing line breaks checkbox is checked in the Editor | C# | Formatting | General options page.
- Wrap if Long or Multiline - adds line breaks to wrap lines that exceed the margin.
- Simple Wrap - adds line breaks to wrap those expression elements that exceed the margin.
- Wrap - wraps all code elements regardless of the right margin.
The line break’s position before or after the code element.
- Align by - allows CodeRush to align wrapped lines by an element at the first line.
- Indent - allows you to specify wrapped lines indentation.
Note
CodeRush produces indents in the same way as Visual Studio formatting based on an .editorconfig file or Visual Studio’s indentation options (Text Editor\ C# \Tabs) if these options do not exist in the .editorconfig file.
- Tolerance - you can specify the minimum parameter count for which the formatting rule is applied. This option is available for arguments, parameters, array initializers, collection initializers, and object initializers.
- Wrap first - you can define whether to wrap the first element in an assignment expression.
The image below shows the wrapping settings for the Arguments item.