How to comment multiple lines in the code


#1

some times i test more than one piece of code how to comment ( add # ) or uncomment ( remove the # ) multiple lines at once


#2

I haven’t found any ways to multi-line comment in CC (Python).
Apparently, consecutive single-line comments are favoured in Python. This is not a problem because most editors, including CodeCombat’s, have shortcuts to do this.

The default editor configuration in CC uses Ace key bindings (can be changed in the options).
To comment multiple lines, just select the text and press Ctrl-/ (Cmd-/ on Mac)

Find more Ace keyboard shortcuts here.
(It turns out you can even Find text using Ctrl-F)


#3

An addition for the interested reader:


For Javascript the multi-line comment looks like this:

// Single line

/*
Multi-
line-
comment
*/

/*
 * Also a 
 * Multiline-
 * comment, but
 * seen more often.
 */

The * (except the very first and last ones) are completely irrelevant, but provide a good look and a baseline for the reader. When presenting code I usually prefer the second variant.


#4

@zuf , Thanks that helps


#5

Just what I was looking for! Very useful when you’re trying out bits of code :slight_smile: