Skip to content

Instantly share code, notes, and snippets.

@dk949
Last active March 14, 2025 19:59
Show Gist options
  • Save dk949/88b2652284234f723decaeb84db2576c to your computer and use it in GitHub Desktop.
Save dk949/88b2652284234f723decaeb84db2576c to your computer and use it in GitHub Desktop.
Comments in different programming languages

Comments in different programming languages

This document lists comment styles and languages (and dialects) that use it. The list is based on the one used in NERD commenter.

Comment types are grouped by the types of symbols used. Each example is organised as a comment block followed by a list of languages.

Note1: the number of languages is quite large, and much of this document was auto generated, hence some of the languages may not in fact be languages...

Note2: the names for the languages are the identifiers used by vim unless manually corrected, this may not always be ideal and in some cases will cause duplication.

TOC

Hash

(like python)

These languages use one or more hashes (#) for a single line comment and something similar (see below) for block comments.

# this is a comment

aap, ampl, ansible, apache, apachestyle, awk, bc, cairo, cfg, cl, cmake, conkyrc, crontab, cucumber, cython, dakota, debcontrol, debsources, desktop, dhcpd, diff, dockerfile, ebuild, ecd, eclass, elixir, elmfilt, ember-script, esmtprc, exim, expect, exports, fancy, fgl, fstab, fvwm, gdb, gdscript3, gentoo-conf-d, gentoo-env-d, gentoo-init-d, gentoo-make-conf, gentoo-package-keywords, gentoo-package-mask, gentoo-package-use, gitcommit, gitignore, gitrebase, gnuplot, gtkrc, hb, hog, hostsaccess, hxml, ia64, icon, inittab, jproperties, kivy, ldif, lilo, lout, lss, lynx, maple, meson, mips, mirah, mush, nginx, nimrod, nix, nsis, ntp, ora, paludis-use-conf, pcap, perl, pine, po, praat, privoxy, ps1, psf, ptcap, puppet, pyrex, python, radiance, ratpoison, rego, remind, resolv, rib, robot, robots, rspec, ruby, scons, sdc, sed, sh, shader_test, sls, sm, snakemake, snippets, snnsnet, snnspat, snnsres, spec, squid, sshconfig, sshdconfig, tcl, tf, tidy, tli, tmux, toml, tsscl, ttl, tup, upstart, vgrindefs, vrml, wget, wml, xmath, yaml, r, renpy

# this is a comment
### this is an enclosed comment ###

coffeescript

# this is a comment
## this is also a comment

fluent

## this is a comment

htmlcheetah, mako, webmacro

# this is an enclosed comment /#

htmlos

#  this is a comment
#= this is an enclosed comment =#

julia

## this is a comment
#* this is an enclosed comment *#

velocity

\# this is a comment

groff

Double slash

(like c++)

These languages mainly use some combination of forward slashes (/) and asterisks (*) for line and block comments.

// this is a comment
/* this is an enclosed comment */

acedb, actionscript, asy, bind-named, c, cg, ch, clean, clipper, cpp, cs, cuda, d, dot, dylan, fx, glsl, go, groovy, h, haxe, hercules, hyphy, idl, ishd, java, javacc, javascript, javascript.jquery, json5, jsonc, jsonnet, kscript, lpc, mel, named, objc, objcpp, objj, ooc, pccts, php, pike, pilrc, plm, pov, processing, proto, rc, rust, scala, scss, slice, stan, stp, supercollider, swift, systemverilog, tads, teak, tsalt, typescript, uc, vala, vera, verilog, verilog_systemverilog, sass

// this is a comment

asciidoc, bib, calibre, cocci, cypher, faust, openroad, ox, pfmain, scilab, specman, xkb, zig

// this is a comment
(* this is an enclosed comment *)

ats, fsharp

//- this is a comment
// this is also a comment

jade, pug

// this is a comment
{/* this is an enclosed comment */}

javascriptreact, typescriptreact

// this is a comment
* this is also a comment

spectre

/ this is a comment

emblem

/* this is a comment

aml, natural, vsejcl

/* this is an enclosed comment */

less

Tags

(like html)

In these languages comments look like tags. i.e. enclosed in angle brackets (<...>) or some other bracket type.

' this is a comment
<!-- this is an enclosed comment -->

aspvbs

<!--- this is an enclosed comment --->

cf

<!-- this is an enclosed comment -->

docbk, html, markdown, pandoc, rmarkdown, sgmllnx, wikipedia, xml

<%# this is an enclosed comment %>
<!-- this is also an enclosed comment -->

eruby

<!-- this is an enclosed comment -->
{# this is also an enclosed comment #}

genshi

<%-- this is an enclosed comment --%>
<!-- this is also an enclosed comment -->

gsp

{# this is an enclosed comment #}
<!-- this is also an enclosed comment -->

jinja

<%-- this is an enclosed comment --%>

jsp

<!--- this is an enclosed comment -->

mkd

<! this is an enclosed comment >

smil

<dtml-comment> this is an enclosed comment </dtml-comment>

dtml

<% # this is an enclosed comment %>

mason

{% comment %} this is an enclosed comment {% endcomment %}
{# this is also an enclosed comment #}

django, htmldjango

{{!--  this is an enclosed comment  --}}

handlebars, hbs

{% comment %} this is an enclosed comment {% endcomment %}

liquid

{{! this is an enclosed comment }}

mustache

Dashes and braces

(like haskell)

These languages use some combination of dashes and curly braces for line and enclosed comments.

-- this is a comment

ada, ahdl, asn, cabal, csp, eiffel, gdmo, lace, mib, occam, sa, sather, vhdl

-- this is a comment
(* this is an enclosed comment *)

applescript

{{-- this is an enclosed comment --}}

blade, laravel

-- this is an enclosed comment --

catalog, sgmldecl

-- this is a comment
{-- this is an enclosed comment --}

elm

-- this is a comment
{- this is an enclosed comment -}

haskell, idris

>--  this is a comment
>{- this is an enclosed comment -}

literal haskell

--  this is a comment

hive, sqlforms, sqlj

-- this is a comment
/- this is an enclosed comment -/

lean

-- this is a comment
--[[ this is an enclosed comment ]]

lua

Semicolon

(like various assembly languages)

These languages use a semicolon for single line comments. Some languages in this section may also belong to other sections, but using semicolons is more unique, so they are grouped here.

; this is a comment

amiga, armasm, asm68k, asterisk, autoit, bindzone, clojure, def, dns, dosini, dracula, dsl, fasm, gitconfig, idlang, iss, jess, kix, llvm, masm, monk, nagios, nasm, ncf, newlisp, omnimark, pic, povini, rebol, registry, scsh, skill, smith, tags, tasm, winbatch, wvdial, z8a, ppwiz

; this is a comment
/* this is an enclosed comment */

autohotkey

; this is a comment
#| this is an enclosed comment |#

lisp, racket, scheme, ss

; this is a comment
# this is also a comment

asm, samba

; this is also a comment
# this is a comment

ledger

Keyword

(like BASIC)

These languages use a keyword to start a comment. Some also have an ending symbol. Some also have alternative syntax using symbols instead of keywords.

C this is an enclosed comment $

atlas

' this is a comment
REM  this is also a comment

basic

% this is a comment
comment this is an enclosed comment;

simula

CVS: this is a comment

cvs

REM  this is a comment
:: this is also a comment

dos-batch

GEEK_COMMENT: this is a comment

geek

dnl  this is a comment

m4

REM this is a comment

opl

@c  this is a comment

texinfo

comment = ' this is an enclosed comment '

tssgm

Percent

(like Tex)

These languages use a percent (%) for single line comments and include a percent in the block comments.

% this is a comment

abc, bbx, bst, ist, lilypond, lprolog, lytex, map, pdf, postscr, ppd, slang, slrnrc, tex, texmf, txt2tags, virata, sile, erlang

% this is a comment
%* this is an enclosed comment *%

asp

% this is a comment
%{ this is an enclosed comment %}

matlab

Miscellaneous

These languages either form very small groups or could fit multiple other categories, so they are loosely grouped here under subheadings.

Quote

' this is a comment

ave, elf, lscript, vb

' this is a comment
{ this is an enclosed comment }

spin

." this is a comment

man

.\" this is a comment

mandoc, troff

" this is a comment

nroff, st, vim

Exclamation mark

! this is a comment

apdl, fortran, incar, inform, molpro, poscar, rgb, sqr, uc4, uil, vasp, xdefaults, xpm2

!  this is a comment
!#  this is also a comment

factor

Dollar

$! this is a comment

dcl

$ this is an enclosed comment $

model

$ this is a comment
/* this is an enclosed comment */

patran

$ this is a comment

master, nastran, sinda, spice, tak, trasys

Brackets

(* this is an enclosed comment *)

augeas, coq, jgraph, lotos, mma, modula2, modula3, ocaml, omlet, scilla, sml

{ this is an enclosed comment }
(* this is also an enclosed comment *)

pascal

(: this is an enclosed comment :)

xquery

Braces

{* this is an enclosed comment *}

smarty

{# this is an enclosed comment #}

twig

Multiple categories

// this is a comment
# this is also a comment

hocon

% this is a comment
# this is also a comment

octave

--  this is a comment
/* this is an enclosed comment */

plsql, sql

% this is a comment
/* this is an enclosed comment */

prolog, minizinc

# this is a comment
/* this is an enclosed comment */

sentinel, terraform

Everything else

:: this is a comment

btm

* this is a comment

caos, cterm, form, foxpro, gams, sicad, snobol4

-* this is a comment

focexec

-# this is a comment
/ this is also a comment

haml

/ this is a comment
/! this is also a comment

slim

@GerardEngland
Copy link

looks confusing
geometry dash meltdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment