简体   繁体   中英

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.

But in CSS files, this command formats the document in a way i don't quite like.

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:

  • Compact rules
  • Semi-expanded
  • Expanded

None of these meet your requirements. The formatting options for C# (and other languages) are much more customizable.

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)"

and it will turn your 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.)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM