In Editors, You can select text and use the shortcut key to comment and uncomment the code block.

Atom also provides a short-cut key to comment and uncomment the code.

How to comment code block in Atom Editor

In Atom, It only supports single-line comments, Which means if you selected multiple comment lines, It adds single-level comments to each line.

Here are steps to add comments on a code block.

  • First, select the single or multiple lines
  • Next run below Shortcut command add Single line comments
    • Ctrl + I in Windows and Linux
    • ⌘ + I in MacOS
  • To uncomment the commented text, Repeat the same command.

It creates a single-line comment as seen below.

// single line comment

If you comment multiple lines, It adds single-line comments as seen below.

// line 1
// line 2

It does not support block-level comments.

Block-level comments are code blocks that span multiple lines using the below syntax.

/**
 * block-level syntax
 */

So, It does not support block-level comments natively, You can extend by installing plugins.

How to add block-level comments in Atom text editor.

Following are steps to install block-level comments.

  • File > Settings > Settings window opens

  • Select the Installs tab and type “Block comment” in the search box

  • It installs Block comment

  • use a shortcut to comment on the code block

    • CTRL + Shift + I in Windows, Linux

    • ⌘ + Shift + I in MacOS

      Here is a commented code after applying the shortcut.

      /*
      comment in line1
      comment in line2
      */
      
  • To uncomment the code, use the same shortcut commands again.