Remark multiple lines in a Yaml, Terraform, a Json files or PowerShell.

Tzahi Kolber
3 min readJun 18, 2023

Often, I and many other decoders, get into a situation where you want to test only part of your code, or you need to make a temporary change in your Yaml / Json files or in PowerShell scripts.

Remarking multiple lines in a Yaml, Terraform or a Json files

You can remark multiple lines in a Yaml, Terraform or a Json files, using the Visual Studio Code (VS Code) or the Azure DevOps editor.
Just open the file using VS Code in our example and act as the following:

  1. Mark the relevant lines you would like to remark.
  2. Press the keyboard shortcut: Ctrl + / (Windows/Linux) or Cmd + / (Mac).
    This shortcut toggles the comment status of the selected rows, adding or removing the comment characters.
Remarking a Terraform file.
Remarking a Yaml file.
  • As for a Json file, the comment character is //, so the selected rows will have // added at the beginning of each line.
Remarking a Json file.
  • Other option, is to manually mark only the first row with /*and */ at the last row you would like to mark, as the following example:

In the example above, the lines between the /*and */ are considered comments and will be ignored by the Json when executing the script. You can add as many lines as you need within the comment block.

Remarking multiple lines in a PowerShell file

Also in PowerShell, you can remark multiple lines, using the Visual Studio Code (VS Code) as the same method for remarking multiple lines in Yaml or Terraform, using the Ctrl + / shortcut:

Remarking a PowerShell script file using VS Code.
  • In case you would like to remark multiple lines in PowerShell Integrated Scripting Environment (ISE), act as the following:
  1. Mark the relevant lines you would like to remark.
  2. Press the keyboard shortcut: Ctrl + H
  3. Type ^in Find what
  4. Type #in Replace with
  5. Check the Regular Expression check box
  6. Click on Replace All

After the change, the lines will be remarked:

  • Other option, is to manually mark only the first row with <#and #> at the last row you would like to mark, as the following example:

In the example above, the lines between <# and #> are considered comments and will be ignored by PowerShell when executing the script. You can add as many lines as you need within the comment block.

Conclusion

Remarking multiple lines for testing or debugging are very useful.
Using the tricks above, can make your scripting and coding life, much easier and efficient!

--

--

Tzahi Kolber

During the last 15 years, I was working as a Senior PFE within Exchange area at Microsoft. Now I’m Senior Consult as Azure IAAS, PowerShell & Automations.