Keyboard Shortcut to create a comment block

Welcome Forums General PowerShell Q&A Keyboard Shortcut to create a comment block

This topic contains 3 replies, has 3 voices, and was last updated by

 
Participant
2 years, 10 months ago.

  • Author
    Posts
  • #33484

    Participant
    Points: 0
    Rank: Member

    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

    Member
    Points: 0
    Rank: Member

    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

    Participant
    Points: 1
    Rank: Member

    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

    Participant
    Points: 0
    Rank: Member

    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.

The topic ‘Keyboard Shortcut to create a comment block’ is closed to new replies.