Domanda

In eclipse, I'd like to select a section of code with my mouse and then hit some sort of keyboard shortcut that causes the selection to be surrounded like so:

// [region]
public void someFunction() {
    ...
}
// [endregion]

Where the code is surrounded by the (user defined) comment lines "// [region]" and "// [endregion]" How would I do this? In netbeans, you can do something similar as referenced here: http://wiki.netbeans.org/SurroundWithCodeFolding

È stato utile?

Soluzione

Yes you can cover a single or block of statements with if, do, for, while etc etc.

Select a single or block of statements then press Alt + Shift + Z

You will see the below popup. Choose the appropriate option. Hit Enter

enter image description here

But you asking to cover a set of statements with method, for this you have to refractor the code.

Select a single or block of statements then press Shift + Alt + M

Then a dialog will appear, fill up the details and click on OK button.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top