How To Wrap All Long Lines in Your Code
- 2 minutes to read
Follow the steps below to configure the line wrapping code style and apply this format to all the code in your project:
- Open CodeRush configuration using the CodeRush | Options menu item.
Open the Editor | C# | Formatting | General options page and configure the Right margin.
NOTE
You can enable the Right Margin Line in code editor using the Editor | All Languages | Right Margin Line options page.
- Switch to the Editor | C# | Formatting | Wrapping options page.
Configure different code elements' wrapping style.
You can select one of the following wrapping options in most cases:
- No Wrap — adds no extra line breaks. Removes existing line breaks if the Editor | C# | Formatting | General | Keep existing line breaks checkbox is checked.
- Simple Wrap — wraps only those code elements that exceeds the margin by adding the minimum number of line breaks.
- Wrap if Long or Multiline — wraps each code element if the line exceeds the margin by adding the maximum number of line breaks.
- Wrap — wraps all code elements regardless of the right margin.
- Configure other formatting options to match your code style.
- Switch to the Editor | C# | Code Cleanup options page.
Check the Format document item and uncheck any unnecessary items.
- Save the configuration using the OK button.
- Open a source code file.
Use the Code Cleanup toolbar button to run Code Cleanup.
You can perform Code Cleanup on the entire project using the Cleanup Project item of the project’s context menu.