I love Visual Studio's ability to auto format (CTRL + K,D). However, in HTML if you have something like:
<h1><%# Eval("SomeField") %></h1>
It gets formatted this way:
<h1>
<%# Eval("SomeField") %></h1>
I'm fairly certain that the line break after the <h1>
tag is caused by Visual Studio's formatting rules for embedded code blocks. However I don't know where to edit those settings. All of the other rules are under Tools > Options > Text Editor.
Does anyone have any ideas?
Many thanks!
The code formatting is available in Visual Studio Code (VSCode) through the following shortcuts or key combinations: On Windows Shift + Alt + F. On macOS Shift + Option + F. On Linux Ctrl + Shift + I.
The code formatting is available in Visual Studio Code through the following shortcuts: On Windows Shift + Alt + F. On Mac Shift + Option + F. On Linux Ctrl + Shift + I.
Right click any HTML file in the Solution Explorer in Visual Studio and click on Open with. Select the HTML (web forms) editor.
Tools > Options > Text Editor > Html > Formatting
Tag wrapping section -> Tag Specific Options...
Default Settings (there are 4) - Change all the "Line breaks:" to "Before and after"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With