Is there a macro in the Visual Studio editor to remove all comments from a VB.NET source file?
+2
A:
Using menu Edit -> Find and Replace -> Quick Replace with Regular expressions
Find what: ^{.+}'.+$
Replace with: \1
will replace
text ' comment
to
text
abatishchev
2010-04-01 19:48:06
@abatishchev - It removes the entire line! Which I obviously do not want. e.g. `Dim path As String ' temporary file path` - would remove the entire line.
2010-04-01 19:59:36
@roygbiv: My first variant will remove the whole line. The current one - will not
abatishchev
2010-04-01 20:03:12
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
abatishchev
2010-04-01 20:16:59
Yes, thank you friend this works.
2010-04-01 20:22:19
A:
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.
Justin Gregoire
2010-04-01 19:49:45