Comments do use to describe meaningful messages about the line of code.
Usually, in any programming language, There are two types of comments
- Inline or single-line comments
- Block-level or multiple line comments
YAML’s syntax supports inline comments. Block-level comments, on the other hand, are not supported.
Inline comments in yaml
Inline comments are comments declared at the line of code Hashtag symbol is used at the start of the line to tell the processor that it is a comment
Here is a code for the
yaml inline comments example.
# comments Syntax example in YAML file or #### comments example
It is called single-line comments. Each comment line starts with a hashtag(#) symbol and blank space followed by a description. Each line will end with a new line break.
Block level comments in yaml
Block comments are to comment the multiple lines. YAML has no support for block comments by default, You can use multiple inline comments with single-line syntax.
# block level comment example # comment line 1 # comment line 2 # comment line 3
Important notes of comments in YAML
YAML processor ignores comments.
It is to document about the line of code enables developers life is easy to understand
Support short cut commands by different IDE
Comment and uncomment in Editor
Let’s see how do we comment or uncomment in different popular editors There are shortcut keys used to comment in popular editors
Comment in eclipse
Eclipse by default has no support for YAML, First, install the YEdit plugin from the Eclipse marketplace.
This editor is used to Edit, Syntax highlight, Checking, and content highlight with multiple colors.
Select the line which you want to comment code
Please issue a shortcut command
CTRL + Shift + C to comment on the code.
select and run the shortcut command again to remove the comments from the code.
The other way is using the menu or context menu option.
Select the line of code
Right-click and select
Comment and uncomment in Visual Studio code
VSCode by default has support for YAML editor features.
Please select the line of code, or multiple lines of code, that you’d like to comment.
and issue a shortcut command
CTRL + / to comment on the text
To uncomment the text, rerun the previous command.
How to comment in ATOM editor
In Atom editor, you can select the multiple lines issue following commands to comment.
- ctrl + / in windows and linux
- cmd + / in mac OS