Sometimes, I need to comment out a whole file. Normally, I'd just wrap the class in /* */
, but that doesn't work if there's already existing comments inside the class:
/*
class foo {
/**
* Great documentation - but this breaks my
* whole-file-comment!
*/
public void dooFoo() {
}
}
*/
Is there any way to come around this? Preferably without inserting //
-comments at every line.
Preferably without inserting //-comments at every line.
That's the simplest way to do it. Most IDEs have keyboard shortcuts to add or remove //
at the start of every line in a selection - so you just need to select the whole file (e.g. Ctrl-A) and then press the shortcut.
Visual Studio: Ctrl+K, Ctrl+C to comment; Ctrl+K, Ctrl+U to uncomment.
Eclipse and IntelliJ: Ctrl+/ to toggle.
IntelliJ: Ctrl+Shift+/ to use /* ... */
, handling embedded existing comment blocks appropriately.
NetBeans: Ctrl+Shift+C to toggle.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With