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.


  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:


  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.



CodeRush provides numerous Formatting options to configure code style.

  1. Click Apply to save code style changes.


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


  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.



  • Save your project file.

CodeRush applies the Format document rule in code cleanup.