Disable auto-indent of comments with Visual Studio 2015

时间秒杀一切 提交于 2019-12-06 18:48:36

问题


I have looked and searched for ways to disable indentation of comments when I save C# files in Visual Studio 2015 with Resharper 9.0.0.0 installed.

I'd like to pseudocode before I start writing actual code. However I have been tweaking with both Visual studio's and Resharper's settings to no avail. So for example I want the comments to look like:

  private string ToggleString(string input)
    {
        // If input.length is between 1-100
            // All the uppercase letters converted to lowercase.
            // All the lowercase letters converted to uppercase
        // else
            // Return a constructive message.

        return input;
     }

When I save CTRL + s it turn out like this:

private string ToggleString(string input)
{
    // If input.length is between 1-100
    // All the uppercase letters converted to lowercase.
    // All the lowercase letters converted to uppercase
    // else
    // Return a constructive message.

    return input;
 }

How do I disable the auto-format?


回答1:


In VS 2017 (C++) there is a checkbox for this.

Tools | Options | Text  Editor | C/C++ | Formatting | Indentation | Preserve indentation of comments

Unchecking it fixed annoying comment auto-formatting. Maybe the same option exists in VS 2015.




回答2:


I don't think its possible to just omit inline comments formatting and still do other code cleanup.

You can try maybe moving to XML Doc comments and try with the setting as in the picture



来源:https://stackoverflow.com/questions/43899505/disable-auto-indent-of-comments-with-visual-studio-2015

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!