Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove all C# methods/properties/fields "summary" comments (starting with ///) in current document in Visual Studio with one shot?

How to remove all C# methods/properties/fields "summary" comments

(starting with ///)

in current document in Visual Studio with one shot?

In other words convert this:

/// <summary>
/// Very stupid comment generated with very stupid tool
/// </summary>
protected void MyMethod
{

}

Into this:

protected void MyMethod
{

}
like image 969
Michał Kuliński Avatar asked Nov 02 '12 08:11

Michał Kuliński


People also ask

What is remove () in C?

C library function - remove() The C library function int remove(const char *filename) deletes the given filename so that it is no longer accessible.

How do I remove all letters from a string?

str = str. replaceAll("[^\\d]", ""); You can try this java code in a function by taking the input value and returning the replaced value as per your requirement.


2 Answers

How about

  • Ctrl+H for quick replace
  • Mark Use : Regular expressions
  • Enter in Find what field following expression ^.*\/\/\/.*$\n (shortly - line with /// pattern)
  • Leave Replace with field empty
  • Make sure that you Look in in Current Document
  • Click Replace All
like image 112
Michał Kuliński Avatar answered Oct 22 '22 04:10

Michał Kuliński


Regex pattern ^.*\/\/\/ ?<summary>.*\n(?:^.*\/\/\/.*$\n)* will be more suitable in this case because it will match whole summary comment at once.

  • ^.*\/\/\/ ?<summary>.*\n - matches line with /// <summary> text (with optional space after slashes)
  • (?:)+ - non-capturing group, repeated zero or more times
  • ^ - beginning of the line
  • .* - any characters
  • \/\/\/ - three slashes
  • .* - any characters
  • $ - end of line
  • \n - line break symbol
like image 39
sad_robot Avatar answered Oct 22 '22 06:10

sad_robot