visual-studio-code - 有没有办法排除 html 行在 vscode 中被格式化?

标签 visual-studio-code code-formatting

有没有办法在 vscode 中排除 html 行的格式? (我使用更漂亮的)例如:我像这样手动格式化:

<input 
            (keyup.enter)="createPost(title)" 
            #title type="text" 
            class="form-control" />

它会自动重新格式化为:

<input (keyup.enter)="createPost(title)" #title type="text" class="form-control" />

我尝试使用 pre ,它可以正常工作,但这不是很方便。

这是我最近(不舒服的)解决方案的例子;

 <style>
    pre {
      white-space: normal;
      padding: 0px;
      margin: 0 0;
      border: 0px;
    }
</style>
<div>
    **<pre>**   
    <input 
        (keyup.enter)="createPost(title)" 
        #title type="text" 
        class="form-control" />
    **</pre>**

    <!-- other HTML to be formatted -->

    <ul class="list-group">
        **<pre>**
            <li  
                class="list-group-item" 
                *ngFor="let item of items">
                <p>{{ item.body }}</p>
            </li>
        **</pre>**
    </ul>
</div>

谢谢,公爵

最佳答案

VS Code 本身不执行任何语言的自动格式化。您需要查看您正在使用的扩展程序,以及它是否提供了在保存时禁用自动格式化等功能。

关于visual-studio-code - 有没有办法排除 html 行在 vscode 中被格式化?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48248424/

相关文章:

Eclipse "align fields in columns"随火星变化

c++ - 保存时格式化 C/C++ 代码

code-formatting - 在线代码美化器和格式化程序

typescript - 如何使用 jsDoc 在自定义组件中记录此关键字?

visual-studio-code - Prettier 格式在具有最新 Prettier 扩展版本 (v7.1.0) 的 Mac 上不起作用

C++/G++ 包括来自另一个文件夹的头文件

visual-studio-code - 我什么时候想在 WSL2 :Ubuntu vs VsCode Windows? 中安装 VSCode 扩展

c++ - 最佳 C++ 代码格式化程序/美化程序

Notepad++ 标签向左

css - VS 代码扩展以突出显示重复的 css 属性