ridicurious.com
Powershell, Productivity

Multiline Commenting in PowerShell ISE

In Powershell Ver 3.0 and above you can comment and un-comment multiple lines in one go, using the below trick.

Suppose you have a code and you want to comment all the lines of code starting from Line1 – Line12 like in the below example, obviously you can use Block commenting instead, In which you can comment your code inside comment blocks <# Your Code  #>,

But I’ve a quicker way for you, that can be prove productive in day-to-day scripting

Just press ALT + SHIFT at the first line and use the UP/DOWN Arrow key to navigate to the bottom line just like in the images.

gif1

Drag the cursor till the last line

and more

and more until, you see a straight line like the picture below.

When you are at the last line just press ‘SHIFT + #’  to add  Pound(‘#’) in front of each line, making them all comments.

And, to uncomment any such block you can simply follow the same steps and press delete or backspace to remove the ‘#’.    Quick and Easy !! 😀
Hope you will like this trick, Happy Learning 🙂

~ Courtesy http://www.dexterposh.com/ 

Related posts

Powershell : Providers

Prateek Singh
9 years ago

An Introduction to Powershell

Prateek Singh
9 years ago

3 ways to UnZip Compressed Files using PowerShell

Prateek Singh
5 years ago
Exit mobile version