YAML Comments - Inline And Block Comment
This article is about YAML commenting and how to do inline or block multi-line comment in a YAML file.
In this post, we will learn how to do single line and block (multi-line) comments 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 used for writing configuration files. Its extensions are .yaml or .yml.
YAML also let us comment on the instruction in the configuration files. Here in this post, we will see two ways how to comment on a YAML config file.
Inline (Single-line) Comment in YAML 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 a comment in the YAML language.
Example
# This is a YAML comment
Block (Multiline) Comment in YAML file
YAML does not support block comment. However, we can do block comments or multi-line comments in the YAML file using keyboard shortcuts.
To write a block comment in the YAML file using shortcuts follow the steps below:
Step 1: First select the block of line that you want to comment on.

Step 2: Press Ctrl + /on windows and Linux or cmd + /on MacOS.

This will comment on 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 Posts
Top 40 Git commands with Examples
Check GitHub Account in the Terminal
Solve npm ERR! ENOENT - No Such File or Directory Error
Learn what causes the npm ERR! ENOENT error, steps to troubleshoot it, and how to fix the no such file or directory issue when running npm start or npm install commands on your Node.js project.
How to Clear Cache in NPM?
In this tutorial we will learn how to clean or remove npm cache from Windows, linux and Mac using npm cache clean command.
