Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

How to automatically re-format C# code

Discussion in 'Editor & General Support' started by PickyBiker, May 16, 2020.

  1. PickyBiker

    PickyBiker

    Joined:
    May 11, 2020
    Posts:
    9
    After years of working with Visual Basic, I became quite fond of the fact that the code was automatically reformatted when the return key is pressed. Now that I am learning C#, I have found that CTRL-KD re-formats the code but I do not see how to set it so that it is done automatically when return is pressed.

    If you know how to do that please reply.
     
  2. Antony-Blackett

    Antony-Blackett

    Joined:
    Feb 15, 2011
    Posts:
    1,772
    If you use Visual Studio you get do this with the preferences settings:

    Preferences -> TextEditor -> Behaviour
    and
    Preferences -> TextEditor -> Behaviour -> C#

    This does vary slightly from Visual Studio versions though.
     
  3. PickyBiker

    PickyBiker

    Joined:
    May 11, 2020
    Posts:
    9
    I went to Options-Text Editor-C#-Formatting and checked all the boxes... no help. Clipboard01.jpg
     
  4. Antony-Blackett

    Antony-Blackett

    Joined:
    Feb 15, 2011
    Posts:
    1,772