How to: Add/Remove Line Breaks to/from Code

  • 2 minutes to read

Follow the steps below to configure the code style for blank lines and apply this style to all code in your project:

  1. Open the CodeRush menu in the Visual Studio menu bar and select the Options… item to access the CodeRush configuration options.

    HowTo_CRLF_3

  2. Open the Editor | C# | Formatting | Blank Lines options page and expand the Excessive Blank Lines group to configure the maximum number of blank lines in your code. For example, set the Max blank lines to keep in code option to 1:

    HowTo_CRLF_3

  3. Configure the number of blank lines between regions. Expand the Region group and set Blank lines around to 2, and Blank lines within to 1.

    HowTo_CRLF_4

NOTE

CodeRush provides numerous Formatting options to configure code style.

  1. Click Apply to save code style changes.

    HowTo_CRLF_4

  2. Configure the Format document code cleanup rule:

  • Open the Editor | C# | Code Cleanup options page and choose the Format document rule.

    HowTo_CRLF_4

  • 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.

    Enable

  1. Click OK to save the configuration.

  2. Open a source code file.

  3. Run the Code Cleanup:

  • Right-click the project you want to clean in the Solution Explorer and select CodeRush Cleanup in the context menu.

    CleanUpProject

or

  • Save your project file.

CodeRush applies the Format document rule in code cleanup.

HowTo_CRLF_11