How do you do block comment in yaml?

有没有人知道如何评论yaml中的一行?


YAML supports inline comments, but does not support block comments.

From Wikipedia:

Comments begin with the number sign ( # ), can start anywhere on a line, and continue until the end of the line

A comparison with JSON, also from Wikipedia:

The syntax differences are subtle and seldom arise in practice: JSON allows extended charactersets like UTF-32, YAML requires a space after separators like comma, equals, and colon while JSON does not, and some non-standard implementations of JSON extend the grammar to include Javascript's /* ... */ comments. Handling such edge cases may require light pre-processing of the JSON before parsing as in-line YAML.

# If you want to write
# a block-commented Haiku
# you'll need three pound signs

The spec only describes one way of marking comments:

An explicit comment is marked by a “#” indicator.

That's all. There are no block comments.


Not trying to be smart about it, but if you use Sublime Text for your editor, the steps are:

  • Select the block
  • CMD + / on Mac or CTRL + / on Linux & Windows
  • Profit
  • I'd imagine that other editors have similar functionality too. Which one are you using? I'd be happy to do some digging.

    链接地址: http://www.djcxy.com/p/3410.html

    上一篇: 我可以用'target =“创建链接

    下一篇: 你如何做yaml阻止评论?