YAML - Comments
This tutorial covers YAML tutorials, examples , YAML tutorials - Inline and Block level comments with examples.
Comments are used to describe meaningful message about line of code.
Usually in any technology, There are two types of comments
- Inline or single line comments
- Block level comments
YAML has the syntax support for inline comments , but not for block level comments
Inline comments are comments declared at the line of code Hashtag symbol is used at the start of the line to tell processor that it is comment
Here is an example
# comments Syntax example in YAML file or #### comments example
These only specifies as single line comments. Each line of comment starts with hashtag symbol and blank space followed by description. Each line will end with new line break.
Block level comments
Block comments are to comment the multiple lines . YAML has no support for block comments by default, You can use multiple inline comments
# block level comment example # comment line 1 # comment line 2 # comment line 3
Important notes of comments in YAML
Comments are ignored by yaml processor It useful 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
Eclipse by default has no support for YAML, First install YEdit plugin from Eclipse marketplace
YEdit is editor for yaml , to support Edit,Syntax highlight, Checking and content highligh with multiple colors.
Select the line which you want to comment code
Please issue a shortcut command
CTRL + Shift + C to comment the code
To uncomment the code, Please select and issue the same shortcut command again to revert the comments. The other way is using menu or context menu option
Select the line of code
Right click and select
Visual Studio code command
VSCode by default has support for YAML editor features.
Please select the line or multiple lines of code which you want to comment
and issue a shortcut command
CTRL + / to comment the text
Please issue again same command to uncomment the text