当我在CSS文件中开始一个新的注释时,如何阻止Visual Studio自动添加注释结束字符

时间:2021-03-28 21:16:16

In Visual Studio 2012, when I want to comment out one or more lines in a CSS file using the /* and */ characters, VS always automatically adds the closing comment characters */ right after I type the starting comment characters. So if I start with this block of code:

在Visual Studio 2012中,当我想使用/*和*/字符注释CSS文件中的一行或多行时,VS总是在我输入开始的注释字符后自动添加结束的注释字符*/。如果我从这段代码开始

.appGrid {
    display: -ms-grid;
    -ms-grid-columns: 120px 1fr;
    -ms-grid-rows: 140px 80px 1fr;
}

and I want to comment out the -ms-grid-rows line, I type /* at the beginning of that line. This is what I want to see:

我想注释-ms-grid行,我在这行开头输入/*。这就是我想看到的:

.appGrid {
    display: -ms-grid;
    -ms-grid-columns: 120px 1fr;
/*    -ms-grid-rows: 140px 80px 1fr;
}

Instead, VS adds the */ characters as soon as I finish typing the /* characters, like this:

相反,当我输入完/*字符后,VS会添加*/字符,如下所示:

.appGrid {
    display: -ms-grid;
    -ms-grid-columns: 120px 1fr;
/**/    -ms-grid-rows: 140px 80px 1fr;
}

I then have to manually delete the automatically-added */ and re-add it where I actually want it...in this case at the end of the line I'm trying to comment out.

然后我必须手动删除自动添加的*/并重新添加到我真正想要的地方……在这个例子中,在最后我要注释掉。

How can I stop VS from automatically adding the */ characters? I couldn't find any option to disable this behavior in Tools>Options>TextEditor>CSS.

如何阻止VS自动添加*/字符?在工具>选项>TextEditor>中,我找不到任何禁用此行为的选项。

For reference, I'm using VS2012 Premium.

作为参考,我使用的是VS2012溢价。

2 个解决方案

#1


9  

I'm afraid there isn't an option to change this in Visual Studio, at least not one I can see. I've had the same issue sometimes, and generally use three ways around it:

恐怕在Visual Studio中没有修改的选项,至少我看不到。我有时也遇到过同样的问题,通常用三种方法来解决:

  1. Select the lines to comment out and use the keyboard shortcut: CTRL+K, C
  2. 选择要注释的行并使用键盘快捷方式:CTRL+K, C
  3. Cut the closing */ and paste it at the end of the location
  4. 剪切关闭*/并将其粘贴到位置的末端。
  5. Press CTRL+Z to undo the closing */
  6. 按CTRL+Z以撤消关闭*/。

The first is the best method, but if I've already started typing 2 or 3 are enough to get through the break in flow!

第一个方法是最好的方法,但是如果我已经开始输入2或3,就足以通过流中的中断了!

#2


0  

This is not directly avilable in VS.
You can do this by selecting the content first (including multiple rows) and then pressing the short cut CTRL+K,CTRL+C command in the editor.

这不是直接切换到vs中,您可以先选择内容(包括多行),然后在编辑器中按下快捷键CTRL+K,CTRL+C命令。

#1


9  

I'm afraid there isn't an option to change this in Visual Studio, at least not one I can see. I've had the same issue sometimes, and generally use three ways around it:

恐怕在Visual Studio中没有修改的选项,至少我看不到。我有时也遇到过同样的问题,通常用三种方法来解决:

  1. Select the lines to comment out and use the keyboard shortcut: CTRL+K, C
  2. 选择要注释的行并使用键盘快捷方式:CTRL+K, C
  3. Cut the closing */ and paste it at the end of the location
  4. 剪切关闭*/并将其粘贴到位置的末端。
  5. Press CTRL+Z to undo the closing */
  6. 按CTRL+Z以撤消关闭*/。

The first is the best method, but if I've already started typing 2 or 3 are enough to get through the break in flow!

第一个方法是最好的方法,但是如果我已经开始输入2或3,就足以通过流中的中断了!

#2


0  

This is not directly avilable in VS.
You can do this by selecting the content first (including multiple rows) and then pressing the short cut CTRL+K,CTRL+C command in the editor.

这不是直接切换到vs中,您可以先选择内容(包括多行),然后在编辑器中按下快捷键CTRL+K,CTRL+C命令。