YAML comments
Comments do use to describe meaningful messages about the line of code. Comment text is ignored by the processor during parsing yaml files.
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 The 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 the line of code that enables developers life is easy to understand
Support short-cut commands by different IDE
Comment and uncomment in Editor
Let’s see how we comment or uncomment with 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 in 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 toggle comments
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 on.
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 macOS