views:

387

answers:

2

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
@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.
@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
abatishchev
Yes, thank you friend this works.
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
Interesting suggestions. I knew it would come down to this. Thought there was an easier point and click way.