What key shortcuts are to comment and uncomment code?

前端 未结 7 1624
借酒劲吻你
借酒劲吻你 2020-12-07 13:01

There were Ctrl+E+C (comment) and Ctrl+E+U (uncomment) in older versions, or Ctrl+K+<

相关标签:
7条回答
  • 2020-12-07 13:17

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

    View > Toolbars > Text Editor

    enter image description here

    0 讨论(0)
  • 2020-12-07 13:18

    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.

    0 讨论(0)
  • 2020-12-07 13:21

    I went to menu: ToolsOptions.

    EnvironmentKeyboard.

    Show command containing and searched: comment

    I changed Edit.CommentSelection and assigned Ctrl+/ for commenting.

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

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

    0 讨论(0)
  • 2020-12-07 13:28

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

    0 讨论(0)
  • 2020-12-07 13:32

    "commentLine" is the name of function you are looking for. This function coment and uncoment with the same keybinding

    0 讨论(0)
  • 2020-12-07 13:35

    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.)

    0 讨论(0)
提交回复
热议问题