简体   繁体   English

visual studio中的自定义格式文档选项。 格式化CSS标记

[英]Custom format document option in visual studio. Formatting CSS tags

When i work in VS2008, i use the Ctrl+K+D very often as it saves a lot of time. 当我在VS2008中工作时,我经常使用Ctrl + K + D,因为它节省了大量时间。

But in CSS files, this command formats the document in a way i don't quite like. 但是在CSS文件中,此命令以我不太喜欢的方式格式化文档。

For example when i auto format the document, 例如,当我自动格式化文档时,

.Foo
{
width:1px;
height:2px;
}

However, i like to format tags this way, as it is much more easy to read (in my opinion): 但是,我喜欢以这种方式格式化标签,因为它更容易阅读(在我看来):

.Foo
{ width:1px;
  height:2px; }

So, are there any way that i can implement this ? 那么,有什么方法可以实现这个吗?

The "Tag specific options" feature seems to be the thing that i need, but i am not quite sure how to do this. “标签特定选项”功能似乎是我需要的东西,但我不太确定如何做到这一点。

Thanks. 谢谢。

I just looked in the Visual Studio code formatting options and it appears that there are only three options you can choose from: 我只是查看了Visual Studio代码格式化选项,看起来只有三个选项可供您选择:

  • Compact rules 紧凑的规则
  • Semi-expanded 半发泡
  • Expanded 扩展

None of these meet your requirements. 这些都不符合您的要求。 The formatting options for C# (and other languages) are much more customizable. C#(和其他语言)的格式化选项更加可定制。

Visual Studio 2008中CSS文本格式选项对话框的屏幕截图

OK, after a long while i came up with an acceptable solution; 好吧,很长一段时间后我想出了一个可以接受的解决方案;

copy your css (or upload) to this site and at right, select "High (moderate readability, smaller size)" 将您的CSS(或上传)复制到此站点 ,然后选择“高(可读性适中,尺寸较小)”

and it will turn your css 它会变成你的CSS

.foo
{
    font-weight: bold;
    color: #ff0000;
}

into

.foo { font-weight: bold; color: #ff0000; }

(in my case, thats the one i wanted, you can select what you like most, there are five presets and other additional choices.) (就我而言,那就是我想要的那个,你可以选择你最喜欢的,有五个预设和其他额外的选择。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Visual Studio Code 不会格式化 CSS 文档 - Visual Studio Code Will Not Format CSS Document 在Visual Studio 2012中使用CSS Media Queries格式化文档错误 - Format Document bug with CSS Media Queries in Visual Studio 2012 CSS编辑器中选择的Visual Studio格式无法正常工作 - Visual studio formatting of selection in CSS editor not working Visual Studio 代码 CSS 缩进和格式化 - Visual studio code CSS indentation and formatting 如何在Visual Studio中更正CSS格式问题 - How to correct CSS formatting problem in Visual Studio CSS格式在Visual Studio 2013中不可用 - CSS Formatting not available in Visual Studio 2013 如何在 Visual Studio 中查找样式 css 文件。 在带有标签的单选按钮 radiobuttonlist 之间添加空格 - How to find styling css file in Visual Studio. Adding space between radio button radiobuttonlist with label 将自定义 CSS 标签添加到 RMarkdown html 文档 - Adding custom CSS tags to an RMarkdown html document Visual Studio Advanced CSS格式从紧凑扩展到扩展 - Visual Studio Advanced CSS Formatting Beyond Compact to Expanded CSS样式表Visual Studio 2015中的“添加样式规则”选项在哪里? - Where is Add Style Rule option in css stylesheet Visual Studio 2015?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM