I was trying to remove all comments and empty lines in a file with the help of a macro. Now I came up with this solution which deletes the comments(there is some bug descri
I've just checked with the two examples from above, '+{.+}$
should do. Optionally, you could go with ('|'')+{.+}$
but the first solution also replaces the xml-descriptions ).
'''
''' Method Description
'''
'''
Sub Main()
''first comment
Dim a As String = "" 'second comment
End Sub
Edit: if you use ('+{.+}$|^$\n)
it deletes a) all comments and b) all empty lines. However, if you have a comment and a End Sub/Function following, it takes it up one line which results in a compiler error.
Before
'''
'''
'''
'''
Sub Main()
''first comment
Dim a As String = "" 'second comment
End Sub
'''
'''
'''
'''
'''
Public Function asdf() As String
Return "" ' returns nothing
End Function
After
Sub Main()
Dim a As String = ""
End Sub
Public Function asdf() As String
Return ""
End Function
Edit: To delete any empty lines Search Replace the following regex ^$\n
with empty.