我需要在 Visual Studio 11 中禁用 CSS 自动格式。这简直让我抓狂,太可怕了。我记得在 2010 版本中,有一个选项可以禁用任何语言的自动格式化,但现在我找不到它了。每当我写一行并按回车键时,它就会弄乱我的代码。
最合适的格式样式是紧凑规则样式,但它在冒号后面添加了一个空格,并且还将左括号紧接在选择器后面(我将所有括号对齐到公共列)。
I need to disable the CSS auto format in Visual Studio 11. It simply drives me nuts, it's horrible. I remember in version 2010 there was an option to disable auto formatting for any language, but now I can't find it anymore. Whenever I write a line and press enter it messes up my code.
The most appropriate formatting style is the Compact rules style, but it adds a space after the colon, and also it puts the opening bracket immediately after the selector (I align all brackets to a common column).
发布评论
评论(4)
看起来没有一个选择。我检查了正在访问的注册表设置,也看不到任何内容。
我建议您在连接网站上提出问题,或向Visual Studio 用户之声 网站。
It doesn't look like there's an option. I checked through the registry settings being accessed and couldn't see anything there for it either.
I'd suggest you raise an issue on the connect site or add an entry to the Visual Studio User Voice site.
以下是 SCSS 的使用方法。我相信这将是一个与 CSS 类似的过程。
在我的例子中,我使用 Asterisk AEL,它是来自 Asterisk 的自定义脚本。 Ael 看起来像这样 https://wiki.asterisk.org/wiki/display/ AST/AEL+Loops
无论如何,我首先必须通过转到选项然后搜索文件扩展名将
.ael
文件扩展名格式化为 SCSS。因为 AEL 代码不是 SCSS,所以我在选项上搜索了 SCSS,并禁用了几乎所有内容:
现在,Visual Studio 不会标记错误,仍会格式化代码。
Here is how with SCSS. I belive it will be a similar process with CSS.
In my case I am using Asterisk AEL which is a custom script from Asterisk. Ael looks like this https://wiki.asterisk.org/wiki/display/AST/AEL+Loops
Anyways I first had to format
.ael
file extension as SCSS by going to Options then searching for file extensions.Because AEL code is not SCSS I then searched for SCSS on options and disabled mostly everything as:
Now visual studio will not mark errors and will still format the code.
到目前为止,在 RC 中只有紧凑型,正如您所指出的,该选项卡很烦人,但至少它不再将大括号放在类下方。
So far in the RC there is only the compact as you pointed out, the tab is annoying but at least it stops putting the braces below the class.
解决此问题的一种方法(使用 Visual Studio 2010)是不使用 HTML 编辑器。相反,选择打开方式...并使用源代码编辑器。这样做似乎唯一缺少的事情(除了分割视图和设计视图之外)是 CSS 的语法着色。 HTML 仍然是语法颜色的,Intellisense 似乎仍然适用于 CSS 和 HTML。
另外,这是他们为 VS2013 修复的问题:
https://visualstudio.uservoice.com/forums/121579-visual-studio/suggestions/3549819-allow-turning-the-css-auto-formatting-off-completl
One way around this (using Visual Studio 2010) is not to use the HTML editor. Rather, choose Open With... and go with the Source Code Editor instead. Doing this the only thing it seems to be missing (well aside from the split and design views) is syntax coloring for CSS. HTML is still syntax colored, and Intellisense still seems to work for both CSS and HTML.
Also, this is something that they have fixed for VS2013:
https://visualstudio.uservoice.com/forums/121579-visual-studio/suggestions/3549819-allow-turning-the-css-auto-formatting-off-completl