Refactorings – Use Implicit Line Continuation
The Use Implicit Line Continuation is a Visual Basic language specific refactoring available in Visual Studio 2010 that removes redundant line-continuation underscore characters from an entire source file.
Visual Basic language version 10 has been improved in the area of line-continuation characters. Now, there are a lot of places in the code where an underscore is not necessary anymore, which means that Visual Basic is smarter about auto-detecting line continuation scenarios, and as a result, no longer expect you to explicitly indicate that the statement continues on the next code line. For example, the underscore is no longer necessary in the following cases:
- After the following punctuators: comma ‘,’, open parenthesis ‘(‘, open curly brace ‘{‘, begin embedded expression in XML ‘<%=’.
- Before the following punctuators: close parenthesis ‘)’, close curly brace ‘}’, end embedded expression in XML ‘%>’.
- After an open angle bracket ‘<‘ in an attribute context, before a close angle bracket ‘>’ in an attribute context, and after a close angle bracket in a non-file-level attribute context.
- After binary operators in expression contexts.
- Before and after query expression operators.
- and others.
Consider the following code:
To apply the refactoring move the editor caret to one of the underscore characters in the code. Before applying the Use Implicit Continuation refactoring, you can see the preview hint:
Once the refactoring is applied you will get the following result:
Note that a few underscores are left after the refactoring is performed, because they are actually needed in the code. If you remove them, the code is no longer compilable.
—– Products: Refactor! Pro Versions: 11.1 and up VS IDEs: any Updated: Jun/30/2011 ID: R031