1
$\begingroup$

How can I make a full line of code into a comment by typing a single character inserted at start of the line?

In other programming languages I can use characters such as ! , # and language processor will ignore what follows to next newline. I think using (* ... *) is a bit shoddy because it takes six keystrokes.

$\endgroup$
11
  • 2
    $\begingroup$ What exactly is a line ?:D $\endgroup$ – Dr. belisarius Aug 5 '15 at 17:38
  • $\begingroup$ It is what it is. Use a keyboard macro if typing causes such grief. Use a different language if even the thought of it troubles you. $\endgroup$ – ciao Aug 5 '15 at 17:40
  • $\begingroup$ @bel, depends. How wide is your monitor? ;) $\endgroup$ – J. M.'s ennui Aug 5 '15 at 17:45
  • 2
    $\begingroup$ I guess you don't know this: select something, press Alt + /, and presto! $\endgroup$ – J. M.'s ennui Aug 5 '15 at 17:47
  • 1
    $\begingroup$ I extremely rarely type in (* *), but use right-click Un/Comment. $\endgroup$ – Karsten 7. Aug 5 '15 at 18:40
5
$\begingroup$

Mathematica does not support any kind of comment-to-line-end specaial character(s). You will have to resign yourself to living with that. It does support a very useful and easy to apply block un/commenting feature.

I am running on OS X, so the keyboard shortcut for the context (mouse-right-click) menu's Un/Comment command is Cmnd+/. I use that do any kind of line or block un/commenting. Here is how it works.

Suppose I have a line that looks this this

uncommented

When I click anywhere in the line sufficiently many times (three times will do it if I click on data) and type Cmnd+/, it changes to

commented

When I triple-click on the left-most parenthesis three-times, it reverts back to

uncommented

$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.