YAML Comments – Inline And Block Comment

featured Image

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.

 multi line comment in yaml

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

how to multi line comment in yaml

This will comment on the whole block of text in the file.

Note: This keyboard shortcut method works only on the following editors:

  1. Visual Studio Code
  2. Sublime Text Editor
  3. Atom Editor
  4. JetBrains IDE
  5. Eclipse

That’s how you can comment single line or multiple lines in a YAML file.

Related Posts

git commands with example

Top 40 Git commands with Examples

GitHub has become an essential tool for developers to manage, store, and collaborate with other developers on software projects. With its simple powerful git-based version control system, GitHub allows users…

Read more
Check GitHub Account in the Terminal

Check GitHub Account in the Terminal

GitHub is an integral tool for developers to store, manage, and collaborate on software projects with other developers. And as we work more and more in the command line it…

Read more
featured Image

How to make list of objects in Netlify CMS using list and object Widget

Here in this Netlify CMS tutorial we will how easily we can make a list of objects using list and object widgets. This will allow us to add multiple objects…

Read more

Leave a Reply

Your email address will not be published. Required fields are marked *