codemaid icon indicating copy to clipboard operation
codemaid copied to clipboard

Option to disable to formatting of comments

Open JeroenHo opened this issue 6 years ago • 12 comments

Environment

  • Visual Studio version: Visual Studio 2017 15.6.7
  • CodeMaid version: example 10.4
  • Code language: C#

Description

Disable the formatting of comments would be nice Sometimes comments are put on 1 line, where we want it to be on several.

Steps to recreate

// example of // comment that is // put on one line

Current behavior

// example of comment that is put on one line

Expected behavior

// example of // comment that is // put on one line

JeroenHo avatar May 02 '18 12:05 JeroenHo

We have similar scenarios where this would be useful. Are there any tags that could be used to mark a set of comments so that they would be ignored by our general CodeMaid formatting rules?

ericmschmidt avatar May 03 '18 05:05 ericmschmidt

For the original request, you can simply not use the comment formatting functionality? Comment formatting is off by default until turned on.

For the second request, no we don't currently have any conventions for decorating comments that should be ignored by comment formatting. I'm not sure what that would look like, do you have any ideas? I think having to put a tag (comment) around a comment saying don't format this comment would be pretty awkward... :)

codecadwallader avatar May 05 '18 12:05 codecadwallader

As soon as you have even one line in a comment without a leading space, it will be ignored by the formatter.

//example of
// comment that will not
// be formatted

Or any other version of that same idea. If you're suggesting prefixes, I'm assuming you therefor do not mind some extra characters. Consider:

//; something
//; like this?

I hope this helps you out!

w5l avatar May 05 '18 15:05 w5l

My personal preference would be to separate XML comment headers from regular comments. I'd like CodeMaid to fix up the XML comment headers, but leave my other comments alone. If I could turn these options on and off separately, that would solve my problems entirely. If this is already there and I've somehow overlooked it, please let me know.

MelGrubb avatar Sep 10 '18 12:09 MelGrubb

This would be a useful feature to have.

Protiguous avatar Oct 25 '18 04:10 Protiguous

@MelGrubb great idea! Should even be very easy to implement, since the formatter already knows if it's formatting XML or not, it just requires a setting update.

w5l avatar Feb 10 '19 07:02 w5l

I want to lend some support to this as CM is currently messing up our copyright banners, and there's no way to fix this without completely disabling comment formatting. XML comment formatting is very helpful, but disabling it for other types of comments would help make the difference between our team being able to use CM or not.

VVander avatar Oct 08 '20 22:10 VVander

As soon as you have even one line in a comment without a leading space, it will be ignored by the formatter.

//example of
// comment that will not
// be formatted

Or any other version of that same idea. If you're suggesting prefixes, I'm assuming you therefor do not mind some extra characters. Consider:

//; something
//; like this?

I hope this helps you out!

You can also insert a "Zero Width Whitespace" which looks a bit nicer but is more work. Here's a link to easily copy it: https://codepen.io/chriscoyier/pen/iLKwm

This still doesn't fix the "issue" but is in my eyes a "nasty" work around.

NoobInTraining avatar Jul 26 '21 11:07 NoobInTraining

My personal preference would be to separate XML comment headers from regular comments. I'd like CodeMaid to fix up the XML comment headers, but leave my other comments alone. If I could turn these options on and off separately, that would solve my problems entirely. If this is already there and I've somehow overlooked it, please let me know.

@codecadwallader Any thoughts on this?

NoobInTraining avatar Jul 26 '21 11:07 NoobInTraining

Having some different options for XML and non-XML comment formatting makes sense to me. Which all option(s) would fall under that umbrella? It seems like the one that might be of most interest in this thread is "Run format comments during cleanup" but curious if there are others?

codecadwallader avatar Aug 13 '21 12:08 codecadwallader

Also multi-line string literals would be nice to disable auto-formatting for.

n8jhj avatar Nov 16 '22 00:11 n8jhj