Search code examples
c#rider

C# Rider How to disable format/reformat in a block of code?


I've got some C# code that has specific format that I don't want re-formatted by Rider.

Is there some directive I can add to my code to tell Rider that this section shouldn't be reformatted?

Thanks.


Solution

  • To disable auto formatting for some code block you can use formatter directive:

    // @formatter:off
    
    some custom formatted code that should be kept as is.
       
    // @formatter:on 
    

    Possibly you will need to enable it in settings: Settings -> Editor -> Code Style -> Formatter Control tab:

    enter image description here