Keyboard Shortcut to create a comment block

This topic contains 3 replies, has 3 voices, and was last updated by Profile photo of Stuart Fleck Stuart Fleck 11 months ago.

  • Author
    Posts
  • #33484
    Profile photo of Stuart Fleck
    Stuart Fleck
    Participant

    I know that it is possible but i do not remember the keyboard shortcut in ISE to highlight an area of code and create a comment block or Comment out all the lines.

    Any help for my failing memory would be helpful

    Get-BLAhBlah
    Search-BlahBLah
    

    the desired result is being edited out. Simply I am seeking the keyboard shortcut to comment out multiple lines

  • #33485
    Profile photo of Dave Wyatt
    Dave Wyatt
    Moderator

    I don't believe there is a "comment block of code" function in the ISE by default. However, there is a "block select" functionality in the ISE which allows you to type on multiple lines at once. To do that, put your cursor at the start of the first line. Then, while holding Alt + Shift, use your down arrow to move the cursor down to the last line you want to comment. (You're actually block-selecting multiple lines, zero columns). Then just type "# " to inject the hash and space at the beginning of those lines.

    If you wanted to get rid of those comments, you can use Alt+Shift while selecting all of the "# " characters on each commented line, and then you get rid of them all with one press of Backspace or Delete.

  • #33497
    Profile photo of Christian Sandfeld
    Christian Sandfeld
    Participant

    If you have the ISESteroids module loaded, it provides Ctrl+Shift+B as a keyboard shortcut for toggling block comments. However a bug in PowerShell 5.0 prior to build 10586 prevents it from working (atleast on Windows 10).

  • #33653
    Profile photo of Stuart Fleck
    Stuart Fleck
    Participant

    Thank you both. I had seen it used on a you tube presentation that I had watched and they said that Steroids was not needed. @Dave Wyatt that will serve the purpose that I am looking for.

    I appreciate both of you for your feedback.

You must be logged in to reply to this topic.