Problem
When working with aspx files in Visual Studio with ReSharper enabled, inconsistent behavior may be observed when typing <br/> tags. Sometimes a space is added inside the <br />, and other times no space is added.
Cause [Optional]
The inconsistent behavior arises from the interaction between Visual Studio's default formatting and ReSharper's autocompletion settings. Visual Studio's formatting adds a space character before the closing /, while ReSharper's autocompletion removes it, leading to conflicting outcomes.
Resolution
To resolve the issue of inconsistent behavior, follow these steps to adjust ReSharper settings:
- Open Extensions | ReSharper | Options | Environment | IntelliSense | Autopopup settings page.
- Navigate to the HTML tab.
- Set the On punctuation option to: Display but do not preselect.
This setting change will result in the following behavior when typing a <br> tag:
- Pressing the
Tabkey after typing<brwill autocomplete it to<br/>. - Typing the closing
>bracket will result in<br />, following Visual Studio's unique formatting behavior.
Additionally, you can use ReSharper's Code Cleanup feature to standardize code formatting across your files:
- Trigger the Cleanup Code task for a file or the entire solution via Extensions | ReSharper | Edit | Cleanup Code.
- If desired, automate this process:
- Enable the option ReSharper | Options | Code Editing | Code Cleanup | General | Automatically run cleanup when saving a file.
- Add
aspxto the file type mask in the option Only in files matching the mask.
The Code Cleanup feature ensures that all files conform to your predefined formatting preferences, thereby mitigating lingering formatting inconsistencies, even when they occur sporadically during typing.
Comments
0 comments
Please sign in to leave a comment.