Commenting Code Cheatsheet

This is a note to myself about how to put comments in the code that I mainly work with.

comment type
Language(s)
Comment SyntaxNote

inline[1]
AsciiDoc

// comment

removed by Asciidoctor in HTML output

block[2]
AsciiDoc

////
comment
////

 

removed by Asciidoctor in HTML output

inline
BAT and CMD

@rem comment

inline or block
Go Template

{{/* comment */}}

removed by Hugo in HTML output

inline or block
HTML and Markdown

<!-- comment -->

inline
JSON

// comment

allowed only sometimes, e.g. in Visual Studio Code’s settings.json. See stackoverflow.com’s Can comments be used in JSON?

inline
PowerShell, Python, R, Unix shell, and YAML

# comment

inline or block
PowerShell

<# comment #>

requires PowerShell 2.0+

inline or block
SCSS and CSS

/* comment */

not removed by SASS in CSS output

inline or block
SCSS

/*! comment */

not removed by SASS in CSS output

inline
SCSS

// comment

removed by SASS in CSS output

inline
Vim

" comment

block
YAML

commenthack: >
  multi-line
  comment

 

this is a hack that is discussed in stackoverflow.com’s How do you do block comments in YAML?

 

References

Notes


1. An inline comment is also known as a single-line comment.
2. A block comment is also known as a multi-line comment.

Discussion and reactions

All comments are welcome, including relevant links to your site and suggestions for improving this page. Thanks to GitHub and Utterances, the possible reactions are 👍️ 👎️ 😂️ 🎉️ 😕️ ❤️ 🚀️ and 👀️.