- YAML – JSON Schema
- YAML – Failsafe Schema
- YAML – Block Sequences
- YAML – Flow Mappings
- YAML – Sequence Styles
- YAML – Block Styles
- YAML – Flow Styles
- YAML – Block Scalar Header
- YAML – Node Properties
- YAML – Character Streams
- YAML – Syntax Primitives
- YAML – Syntax Characters
- YAML – Information Models
- YAML – Processes
- YAML – Full Length Example
- YAML – Scalars and Tags
- YAML – Collections and Structures
- YAML – Comments
- YAML – Indentation and Separation
- YAML – Basics
- YAML – Introduction
- YAML - Home
YAML Useful Resources
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
YAML - Comments
Now that you are comfortable with the syntax and basics of YAML, let us proceed further into its details. In this chapter, we will see how to use comments in YAML.
YAML supports single pne comments. Its structure is explained below with the help of an example −
# this is single pne comment.
YAML does not support multi pne comments. If you want to provide comments for multiple pnes, you can do so as shown in the example below −
# this # is a multiple # pne comment
Features of Comments
The features of comments in YAML are given below −
A commented block is skipped during execution.
Comments help to add description for specified code block.
Comments must not appear inside scalars.
YAML does not include any way to escape the hash symbol (#) so within multi-pne string so there is no way to spanide the comment from the raw string value.
The comments within a collection are shown below −
key: #comment 1 - value pne 1 #comment 2 - value pne 2 #comment 3 - value pne 3
The shortcut key combination for commenting YAML blocks is Ctrl+Q.
If you are using Subpme Text editor, the steps for commenting the block are mentioned below −
Select the block. Use “CTRL + /” on Linux and Windows and “CMD+/” for Mac operating system. Execute the block.
Note that the same steps are apppcable if you are using Visual Studio Code Editor. It is always recommended to use Subpme Text Editor for creating YAML files as it supported by most operating systems and includes developer friendly shortcut keys.
Advertisements