Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to use Visual Studio HTML formatting to format an embedded code block?

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!

like image 822
Dan Avatar asked Jul 15 '09 23:07

Dan


People also ask

How do I format a block of code in Visual Studio?

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.

How do I change the code format in Visual Studio?

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.

Does Visual Studio have an HTML editor?

Right click any HTML file in the Solution Explorer in Visual Studio and click on Open with. Select the HTML (web forms) editor.


1 Answers

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"

like image 73
tman Avatar answered Sep 22 '22 01:09

tman