In this post we will learn how to do single line and block (multi-line) comment in a YAML File.
A YAML (yet another markup language) is a programming language which is known as the human-readable data-serialization language. It is a powerful language that is use for writing configuration files. Its extensions are .yaml
or .yml
.
YAML also let us to comment the instruction in the configuration files. Here in this post we will see two ways on how to comment on a YAML config file.
The common way to do an inline comment in a YAML file is to use the # (hashtag) symbol at the start of the line.
So, anything written after the # (hashtag) symbol till the end of the line will be considered as comment in YAML language.
Example
# This is a YAML comment
YAML do not support block comment . However we can do block comment or multi-line comment in YAML file using keyboard shortcuts.
To write block comment in YAML file using shortcuts follow the steps below:
Step 1: First select the block of line that you want to comment.
Step 2: Press Ctrl + /
on windows and Linux or cmd + /
on MacOS.
This will comment the whole block of text in the file.
Note: This keyboard shortcut method works only on the following editors:
- Visual Studio Code
- Sublime Text Editor
- Atom Editor
- JetBrains IDE
- Eclipse
That's how you can comment single line or multiple lines in a YAML file.
Related Topics: