Skip to main content
A newer version of this page is available. .

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:

  1. Open CodeRush configuration using the CodeRush | Options menu item.
  2. 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.

  3. Switch to the Editor | C# | Formatting | Wrapping options page.
  4. Configure different code elements' wrapping style.

    HowTo_Wrap_4

    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.
  5. Configure other formatting options to match your code style.
  6. Switch to the Editor | C# | Code Cleanup options page.
  7. Check the Format document item and uncheck any unnecessary items.

    HowTo_FormatDoc

  8. Save the configuration using the OK button.
  9. Open a source code file.
  10. Use the Code Cleanup toolbar button to run Code Cleanup.

    HowTo_Cleanup

  11. HowTo_Wrapping_Result
  12. You can perform Code Cleanup on the entire project using the Cleanup Project item of the project’s context menu.

    HowTo_CleanupProj