How to: Wrap All Long Lines in Code
- 2 minutes to read
Follow the steps below to configure code line wrapping and apply this format to all code in your project:
Open the CodeRush menu in the Visual Studio menu bar and select the Options… item to access the CodeRush configuration options.
Configure the Right margin column size. This option allows you to specify the minimum line length for which a formatting rule is applied:
Open the Editor | C# | Formatting | General options page. Set the Right margin column size field to 60.
Note
Use the Right margin column size option with the “Wrap if long or multiline” option in the Editor | C# | Formatting | Wrapping options page.
Show the right margin line in the code editor (optional):
Open the Editor | All Languages | Right Margin Line options page. Activate the Enable Right Margin Line option.
Configure wrapping style for chained method calls and lambda expression in the Editor | C# | Formatting | Wrapping options page:
Note
CodeRush provides numerous Formatting options to configure the code style.
Click Apply to save the code style changes.
Configure the Format document code cleanup rule:
Open the Editor | C# | Code Cleanup options page and choose the Format document rule.
Enable Apply In Action to allow CodeRush to apply this rule when you call code cleanup.
Enable Apply on Save and Apply Code Cleanup when saving a document options to allow CodeRush to apply this rule in code cleanup before a file is saved.
Click OK to save the configuration.
Open a source code file.
Run Code Cleanup:
Right-click the project you want to clean in the Solution Explorer and select CodeRush Cleanup in the context menu.
or
Save your project file.
CodeRush applies the Format document rule in code cleanup.