简体   繁体   English

Visual Studio C++ 多行注释

[英]Visual Studio C++ Multiline comments

In VS C++ code, if i haven't selected anything or full line selected and press comment selection (Ctrl+K + Ctrl+C) then it will comment the whole line with //在 VS C++ 代码中,如果我没有选择任何内容或选择整行并按下注释选择 (Ctrl+K + Ctrl+C) 那么它将用 // 注释整行

int x = 5;

After Pressing Ctrl+K + Ctrl+C without anything selected or full line selected.按 Ctrl+K + Ctrl+C 后没有选择任何内容或选择整行。

// int x = 5;

Now if I select some part of the line and press comments button again only selected text will be commented (bold means selected)现在,如果我选择该行的某些部分并再次按下注释按钮,则只会对选定的文本进行注释(粗体表示已选择)

int x = 5 ;整数x = 5 ;

After Pressing Ctrl+K + Ctrl+C with x = 5 selected.按 Ctrl+K + Ctrl+C 并选择 x = 5 后。

int /*x = 5*/;

Incase of multiple lines多行的情况

int x = 5;整数x = 5;

int y = 2; int y = 2;

int z = x * 5; int z = x * 5;

And after comments shortcut和评论后快捷方式

int/* x = 5;
int y = 2;
int z =*/ x * 5;

What I want我想要的是

//int x = 5;
//int y = 2;
//int z = x * y;

Now this is what I don't like.现在这是我不喜欢的。 Usually I select multiple lines and press comments button.通常我选择多行并按下评论按钮。 This will comment only the selected characters , but I want all selected lines tobe commented.这将仅评论选定的字符,但我希望对所有选定的行进行评论。 Is there anyway to do that any extension or from visual studio settings I can change that?无论如何,我可以通过任何扩展或从 Visual Studio 设置来更改它吗?

You have to select the whole line (ie from the very first character of the line) in order to use c++ comments for multiple lines too.您必须选择整行(即从该行的第一个字符开始)才能对多行使用 c++ 注释。

Update: if there are comments among the selected lines, Ctrl+K,Ctrl+C will generate C++ style comments even if the selection does not start from the beginning of the lines.更新:如果选中的行之间有注释,Ctrl+K,Ctrl+C 会生成 C++ 风格的注释,即使选择不是从行首开始。

Triple click on the first line and while keeping the mouse button pressed drag to the bottom (end) line.在第一行上单击三次,同时按住鼠标按钮拖动到底部(结束)行。 after that you have easy select the whole lines and pressing the Ctrl+K, Ctrl+C will comment all those lines with "//" in front.之后,您可以轻松选择整行并按 Ctrl+K,Ctrl+C 将在前面用“//”注释所有这些行。

If you select a block of code and use the key sequence Ctrl+K+C, you'll comment out the section of code.如果您选择一个代码块并使用组合键 Ctrl+K+C,您将注释掉该代码段。 Ctrl+K+U will uncomment the code. Ctrl+K+U 将取消注释代码。

Single Line Comment Shortcut单行注释快捷方式

To achieve more than one single line comment, select the lines and use ctrl + / .要实现多行注释,请选择行并使用ctrl + /

According to ques asked, just use the above shortcut, instead of what you are using to achieve what you want.根据 ques 的要求,只需使用上面的快捷方式,而不是使用您正在使用的东西来实现您想要的。

Multiline Comment Shortcut多行注释快捷方式

Additionally, instead of such a long shortcut(mentioned in ques).此外,而不是这么长的快捷方式(在问题中提到)。 To do multiline comments, select the text and use ctrl+shift+a .要进行多行注释,请选择文本并使用ctrl+shift+a

Same shortcuts are used to uncomment.相同的快捷方式用于取消注释。

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

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