none
Format Document (Ctrl+K+D) ignores options for formatting spacing

    Question

  • Hi, I just installed VS2015 and I have following question.

    While editing C# code the formatting defined in the options is applied correctly. If I type int a=0 when I press ; I get

    int a = 0;

    But if I apply the formatting to to document (Edit/Format Document), some empty spaces are removed and this is the result

    int a=0;

    Is there some option that needs to be set (in my VS2013 installation it works)?

    Thank you

    Regards

    Ivan Salvetti

    Thursday, November 26, 2015 2:29 PM

Answers

All replies

  • Hi Ivan Salvetti,

    Both of Visual Studio 2015 Community and Enterprise works on Windows 10 in my side.

    Please try with following steps to troubleshoot your problem.

    1. Please check the settings of shortcut for Edit.FormatDocument in menu Tools -> Options -> Environment -> Keyboard. If not shown as below image, please add it manually. If the same, please go to step 2.
    2. Please make sure you not set the same shortcut for Windows or other third part program.
    3. Run Visual Studio 2015 in safe mode with "Deven.exe /SafeMode" command to prevents all third-party VSPackages from loading when Visual Studio starts, thus ensuring stable execution.
    4. Close all third part software, such as antivirus software.

    Best Regards,
    Weiwei


    Friday, November 27, 2015 7:06 AM
    Moderator
  • Hi Weiwei,

    thank you for the answer.

    I tried your suggestions and if I stard VS in safe mode (without Resharper) the same issue arises also while I am editing code (my colleagues that have the same configuration as I do (Windows 10 - VS2015 professional) don't have the same behavior.

    Here an example, this is what I would expect

    public bool Register(PluginManager PM, MainForm form)
    {
      PM.OnKeyboardDefined += PM_OnKeyboardDefined;
      PM.OnFormBaseInitialized += PM_OnFormBaseInitialized;
      TransactionsForm transForm = form as TransactionsForm;
      return false;
    }

    And here is what I get:

    public bool Register(PluginManager PM, MainForm form)
    {
      PM.OnKeyboardDefined+=PM_OnKeyboardDefined;
      PM.OnFormBaseInitialized+=PM_OnFormBaseInitialized;
      TransactionsForm transForm = formasTransactionsForm;
      return false;
    }

    A you can see not all the empty spaces are removed, but for example removing the spaces before and after "as" invalidates the code.

    Could it be other rules are applied?
    Maybe I will try to repaitr/reinstall VS2015.

    Best Regards
    Ivan

    Friday, November 27, 2015 7:57 AM
  • Hi Ivan Salvetti,

    Do you install Resharper on your Visual Studio? Please try uninstall it to troubleshoot whether this problem related to Resharper.

    Before you repair/reinstall VS2015, please check the ActiveLog.xml under the path of %AppData%\Microsoft\VisualStudio\14.0 first. This file will log all operations when you operate Visual Studio. Please check whether there has any operation log about the Format Document.

    Then please use http://aka.ms/vscollect  to gather the VS and .Net Frameowrk installation logs before reinstall. After using it, you will find vslogs.cab from %temp% folder. Please upload the file to Onedrive and share the link here.

    Best Regards,
    Weiwei

    Friday, November 27, 2015 9:11 AM
    Moderator
  • Hi Weiwei,

    repair or resinstall did not solve the issue.

    What did work was to "Reset all settings" in the "Import and Export settings wizard".

    Thank you.

    Best Regards

    Ivan 

    Friday, November 27, 2015 3:16 PM
  • Hi Ivan Salvetti,

    I'm glad that you have resolved the problem by Reset all settings and thanks for sharing the solution here. Please mark your reply as answer which is benefit to other communities who has the same problem. If any question in future, please feel free to come back to our forum.

    Best Regards,
    Weiwei

    Monday, November 30, 2015 2:18 AM
    Moderator