1

Is there any way to prevent Resharper from reformatting comments? I'd like to put my comments behind the code it self aligned using tabs. Like:

private static IEnumerable<string> GetOperands(string grammar)
    => grammar.Replace(GetOpcode(grammar), "")                      // remove operand from grammar
        .Split(new[] {','}, StringSplitOptions.RemoveEmptyEntries)  // operands are split with a ,
        .Select(s => s.Trim());                                     // remove any whitespace 

However when I do a code cleanup Resharper formats it as:

private static IEnumerable<string> GetOperands(string grammar)
    => grammar.Replace(GetOpcode(grammar), "") // remove operand from grammar
        .Split(new[] {','}, StringSplitOptions.RemoveEmptyEntries) // operands are split with a ,
        .Select(s => s.Trim()); // remove any whitespace 

Which (in my opinion) does not increase the readability.

joell
  • 396
  • 6
  • 17
  • I think this is what you're looking for. http://stackoverflow.com/questions/15618381/completely-disable-formatting-and-completion-in-resharper-for-visual-studio – därko Oct 24 '16 at 08:32
  • Alsow check this one out if the other didn't help. http://stackoverflow.com/questions/10208199/disable-customize-comment-re-formatting-in-resharper-when-using-code-cleanup?rq=1 – därko Oct 24 '16 at 08:42
  • 1
    Well I don't want to disable it entirely and the xml doc is something else than the regular comments. Thanks anyway. – joell Oct 24 '16 at 09:08
  • Either way those comments are formatted they are clutter and would be better without them, you don't need comments to describe what the code does, you write code in such a way that it describes itself. Comments could be used to explain why though (https://blog.codinghorror.com/code-tells-you-how-comments-tell-you-why/) – Piers Myers Oct 25 '16 at 09:28
  • 1
    I appeal to not use such comments =) If you really want to make the code more readable, then extract methods. – Matthias Oct 27 '16 at 10:55
  • 1
    I admit that for this piece of code the comments are clutter. It was just to demonstrate that I align my comments in one column without giving a large example. So the question still stands, can I prevent resharper from removing whitespace before a comment? – joell Oct 27 '16 at 12:15

0 Answers0