Reputation: 23522
In IntelliJ IDEA, is there shortcut to remove surrounding code block (control structure) around selection in a context aware manner? In this example, I would like to remove the outer if block.
Transform this
if (foo) { // Unnecessary if block
a();
if (bar) {
b();
} else {
c();
}
} else {
d();
}
to this
a();
if (bar) {
b();
} else {
c();
}
Upvotes: 6
Views: 2482
Reputation: 26562
Use the Code | Unwrap/Remove
action (Cmd+Shift+Delete on Mac or Ctrl+Shift+Delete on Windows). It will popup a list where you can select which surrounding structure you want to remove.
Upvotes: 13