Skip to content
| Marketplace
Sign in
Visual Studio Code>Formatters>Code ButlerNew to Visual Studio Code? Get it now.
Code Butler

Code Butler

just-seba

|
1,121 installs
| (1) | Free
Code Butler for C# files to clean up your code.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Code Butler for Visual Studio Code

This extension makes use of the dotnet tool code-butler to clean up you C# files.

This tool is heavily inspired by CodeMaid. As it is available as as a dotnet tool and Visual Studio Code extension, this tool will provide similar features.

Features

Using this tool will cleanup your C# file by

  1. reorganizing the layout of the members in the C# file to follow Microsoft's StyleCop conventions
  2. sorting it's using directives
  3. removes trailing whitespace and consecutive blank lines
  4. Executing the Format Document command.

as described below.

Settings

  • Run code cleanup on save (disabled by default)
  • Sort members by alphabet (enabled by default)

Reorganize the layout of members in a C# file to follow Microsoft's StyleCop conventions

First by type:

  1. Field
  2. Constructor
  3. Destructor
  4. Delegate
  5. Event
  6. Enum
  7. Interface
  8. Property
  9. Indexer
  10. Operator
  11. Method
  12. Struct
  13. Class

Then by access modifier:

  1. public
  2. internal
  3. protected
  4. protected internal
  5. private protected
  6. private

Then by additional modifiers:

  1. const
  2. static readonly
  3. static
  4. readonly
  5. none

And finally alphabetically (optional).

Warning: #region ... #endregion is not supported.

Sort using directives

Sorts using directives alphabetically while placing System directives first and taking into account the following order:

  1. "Normal" using directives
  2. Aliased using statements (e.g. using MyAlias = Example.Bar)
  3. Static using statements (e.g. using static System.Math)

Example:

using System;
using Example;
using Example.Foo;
using MyAlias = Example.Bar;
using static System.Math;

Removes trailing whitespace and consecutive blank lines

  • Removes trailing whitespace.
  • Removes consecutive blank lines.

Prerequisites

  • code-butler installed as global dotnet tool.

Usage

Execute command Code Butler: Cleanup C# file while editing a C# file to clean it up.

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft