DEV Community

Hugh Cumper
Hugh Cumper

Posted on

Edit C# without braces, without changing your project

Many younger programmers grew up on the elegance of Python and get irritated by C# filling their screen with needless squiggles that carry no information that wasn't already right there in the indentation. I'm an old programmer and it irritates me! Relief is at hand.
I’ve built ICS — Indented C#, an editor extension that lets you work with an indented view of your C# code.

Your project keeps ordinary .cs files. The compiler, Git and your teammates continue to see C# with braces and semicolons. You can choose the indented view for your own editing.

Here’s a first walkthrough using VS Code.

Start by installing ICS — Indented C# from the Marketplace. The converter is bundled; on first use, Microsoft’s .NET Install Tool can acquire the runtime it needs.

Open a C# file, press F1, and run:

ICS: Open C# as ICS

An editable ICS view opens beside the original C#.

For a small example, take this Invoice.cs:

public class Invoice
{
    public decimal Total(decimal price)
    {
        return price * 1.20m + 5m - 2m;
    }
}
Enter fullscreen mode Exit fullscreen mode

Its ICS view looks like this:

public class Invoice
    public decimal Total(decimal price)
        return price * 1.20m + 5m - 2m
Enter fullscreen mode Exit fullscreen mode

The class and method bodies are expressed through indentation. Their structural braces disappear from the view, along with the statement’s trailing semicolon.

Both panes are editable.

In the ICS pane, change 5m to 7m. After a short pause, the C# pane updates:

return price * 1.20m + 7m - 2m;
Enter fullscreen mode Exit fullscreen mode

You can also edit the C# pane and watch the corresponding ICS view update. Keeping both visible makes it easy to inspect the relationship between what you edit and what your project uses.

There is an important distinction between updating the editor buffer and saving the file.

With VS Code’s Auto Save disabled and ICS’s optional automatic saving left off, live synchronization updates the two editor buffers. When you save a valid, synchronized ICS preview with Ctrl+S, ICS saves the corresponding C# back to the original .cs file.

Opening the view does not add an .ics sidecar beside your source file. Standalone ICS export is a separate, optional workflow.

You can check this yourself:

  1. Open a C# file as ICS.
  2. Make a small edit in the ICS pane.
  3. Wait for the C# pane to update.
  4. Save the ICS preview.
  5. Inspect the .cs file in another editor or your Git diff.

The saved file contains conventional C#. Your existing project continues to build from that file, with its usual build commands and CI configuration.

Indentation does matter in the ICS view: moving a statement into or out of a block changes its structure. The generated C# makes that structure explicit again.

While you are halfway through typing, conversion may temporarily be unavailable. In that case, the other pane keeps its last verified contents and is marked out of date. An incomplete ICS save can preserve a recovery draft without updating the C# source, so check that synchronization has completed before building.

The side-by-side editing and save workflow described here is free. Pro adds optional automation, including displaying only the ICS view and automatically saving paired C# after successful updates.

For a first try, leave the defaults in place and keep both panes visible. That gives you a straightforward way to judge the editing experience and inspect the resulting C#.

ICS also has editor features beyond conversion, including optional project-aware analysis. Those have their own scope and limitations, covered in the VS Code guide.

You can start with one file in an existing project. If you try it, I’d be interested in which kinds of C# become easier—or harder—to read in the indented view.

Install ICS for VS Code · Report a problem or suggest a feature

Top comments (0)