【问题标题】:Why Does VS 2010 'Comment' Keyboard Shortcut Change in C++?为什么 VS 2010 'Comment' 键盘快捷键在 C++ 中发生变化?
【发布时间】:2011-08-08 04:35:20
【问题描述】:

对我来说,Visual Studio 的 Ctrl + KCtrl + C 键盘快捷键是用来注释的——出选定的行。在编辑 C++ 时,这有时使用块 cmets (/* */),有时使用行 cmets (//)。为什么会改变?它如何决定何时使用哪个?

【问题讨论】:

  • +1:我已经好几年没用过VS了,但我记得你描述的行为。好问题。我永远无法弄清楚这种模式。

标签: visual-studio-2010 keyboard-shortcuts


【解决方案1】:

关于该主题的其他讨论:

Visual studio feature - commenting code Ctrl K - Ctrl C

visual studio C++ toggle comment ? comment while not whole line is selected?

基于我自己的修补,以及那些文章中所说的......

它基于选择的开始/结束。每当您从行首开始选择并在行尾结束时,似乎都使用双斜杠//

It will use /* */ notation whenever the selection occurs midway through lines.

IE:

如果我有代码

int main () {
    return 0;
}

并仅突出显示int main,它会将其转换为/*int main*/

如果我突出显示整个代码部分,从缩进选项卡开始,它会将其转换为

/*int main () {
    return 0;
}*/

但如果我突出显示缩进选项卡之前开始的部分,它会将其转换为

//int main () {
//    return 0;
//}

【讨论】:

    【解决方案2】:

    Zhais 回答下的链接摘要。因为跟随链接很难!

    • 选择整行(包括前导空格)将使用//
    • 选择至少一个部分行
      • 如果包含// 评论,将使用//
      • 否则,将使用/* */

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-01-13
      • 1970-01-01
      • 2012-02-04
      • 2011-05-14
      • 2011-04-08
      相关资源
      最近更新 更多