Is there a macro in the Visual Studio editor to remove all comments from a VB.NET source file?
-
Just curious. Why would you want to do this?JohnFx– JohnFx2010-04-01 19:50:45 +00:00Commented Apr 1, 2010 at 19:50
-
I have refactored a module I've been working on - whereby I commented out X lines of code and then rewrote that code above the comment. Now that my code passes all tests I want to remove the commented out code and add appropriate comments to the functions.user113476– user1134762010-04-01 19:55:18 +00:00Commented Apr 1, 2010 at 19:55
Add a comment
|
3 Answers
Using menu Edit -> Find and Replace -> Quick Replace with Regular expressions
Find what: ^{.+}'.+$
Replace with: \1
will replace
text ' comment
to
text
7 Comments
abatishchev
@roygbiv: My first variant will remove the whole line. The current one - will not
abatishchev
Highlights on Find next? Right. The whole line matches. And it will be replaced with the part of it - from the beginning up to the comment sign
Soham Dasgupta
Just tried out your regex. Works great. There is a problem though, if the commented line is like
'' This is a comment then it only deletes ' This is a comment. There is still a ' left in the line.abatishchev
@Soham: Maybe
[']+ will work, should mean ' 1 times or more |
EDIT*
http://bytes.com/topic/visual-basic-net/answers/579000-utility-remove-comments-vb-net-files
has some options.
such as
- write a VB.NET program to do it? should be easy: any line with a single quote as the first character should be removed. and everything AFTER a single quote (even if it's not the first character), provided the quote is not between a pair of double quotes. and the files you send to this program are any *.vb files.
- search and replace with a regular expression would probably be quickest.