Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Commenting out whole file

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.

like image 607
Zar Avatar asked Jan 24 '13 20:01

Zar


1 Answers

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.

like image 92
Jon Skeet Avatar answered Sep 29 '22 19:09

Jon Skeet