What key shortcuts are to comment and uncomment co

2019-01-16 05:04发布

There were Ctrl+E+C (comment) and Ctrl+E+U (uncomment) in older versions, or Ctrl+K+C and Ctrl+K+U. But in VS 2012 I can't see key shortcuts (look at screenshot) ... Maybe should I enable those shortcuts anywhere??? enter image description here

7条回答
【Aperson】
2楼-- · 2019-01-16 05:05

Keyboard accelerators are configurable. You can find out which keyboard accelerators are bound to a command in Tools -> Options on the Environment -> Keyboard page.

These commands are named Edit.CommentSelection and Edit.UncommentSelection.

(With my settings, these are bound to Ctrl+K, Ctrl+C and Ctrl+K, Ctrl+U. I would guess that these are the defaults, at least in the C++ defaults, but I don't know for sure. The best way to find out is to check your settings.)

查看更多
贼婆χ
3楼-- · 2019-01-16 05:09

I know this is an old post. However I didn't see a solution for the question asked.

This is how I did it,

Tools -> Options on the Environment -> Keyboard window

One can alter the default shortcuts following the below steps

  • Select Edit.CommentSelection in the listbox
  • Click on "Remove" button
  • Select "Text Editor" option in the dropdown under "Use new shortcut in:"
  • Press your own shortcut in the textbox under "Press shortcut keys:" Example: Pressing Ctrl+E and then C will give you Ctrl+E, C
  • Click on "Assign" button
  • Repeat the same for Edit.UnCommentSelection (Ctrl+E, U)
查看更多
何必那么认真
4楼-- · 2019-01-16 05:12

From your screenshot it appears you have Resharper installed.

Depending on the key binding options you chose when you installed it, some of your standard shortcuts may now be redirected to ReSharper commands. It's worth checking, for example Ctrl+E, C is used by R# for the code cleanup dialog.

查看更多
甜甜的少女心
5楼-- · 2019-01-16 05:13

Use the keys CtrlK,C to comment out the line and CtrlK,U to uncomment the line.

查看更多
Viruses.
6楼-- · 2019-01-16 05:13

I went to menu: tools > options.

Environment > Keyboard.

Show command containing and searched: comment

Changed Edit.CommentSelection and Assigned Ctrl+/ for commenting.

And I left Ctrl+K then U for the the Edit.UncommentSelection.

These could be tweaked to the user's preference as to what key they would prefer for commenting/uncommenting.

查看更多
手持菜刀,她持情操
7楼-- · 2019-01-16 05:25

You can also add the toolbar in Visual Studio to have the buttons available.

View > Toolbars > Text Editor

enter image description here

查看更多
登录 后发表回答