[SOLVED] Looking for an Atom Package to Comment Out console.log in all files?


I use console.log for all kinds of reasons during development, but mostly for checking that certain events and such are occurring when i think they should in my code.

Cleaning that up manually however, becomes a more daunting task with each line I write. Is there a package that will comment out my console.log lines in javascript?

I found one that removes all console.log lines, but I don’t want to remove them as they can still be useful in debugging at times.



Try this ->

NOTE: “Have project open” means the project folder is available in the tree-view of Atom.
FILE > Open Folder can help with that.

To keep the indentation and ignore lines that are already commented out ->
SEARCH. . . . ^([ \t]*)(console[.]log)
REPLACE. . . $1// $2

Note… this will only work if console.log()
is at the start of the line (ignoring white-spaces).
Please confirm working before deploying everywhere.


Great answer, and yep about a half hour after I posted the question it dawned on me to just use Find and Replace all, and that worked perfectly. Thanks.


Thanks for the useful tip. To uncomment them would there be a similar Find-Replace? Thanks again.


Thank you for the acknowledgement.

The concept would be the same but the search pattern would look different. How is your skills at constructing regular expressions phrases?

If you wish to continue this conversation, I would suggest you be specific on what you wish to do.


I was hoping to do the opposite. Have all lines that are commented and start with console.log become uncommented. I’m not familiar enough with regex. Thanks.


Try the following ->

SEARCH .... ^([ \t]*)[/][/]([ \t]*)(console[.]log)
REPLACE ... $1$3

Or simply do a search without regular expressions:
(.* deselected)

SEARCH .... // console.log
REPLACE ... console.log


Great point about not even needing regular expressions!! Thanks again.