简体   繁体   English

如何在 IntelliJ IDEA 中删除周围的代码块?

[英]How to remove surrounding code block in IntelliJ IDEA?

In IntelliJ IDEA, is there shortcut to remove surrounding code block (control structure) around selection in a context aware manner?在 IntelliJ IDEA 中,是否有快捷方式以上下文感知方式删除围绕选择的周围代码块(控制结构)? In this example, I would like to remove the outer if block.在此示例中,我想删除外部 if 块。

Transform this改变这个

if (foo) { // Unnecessary if block

  a();

  if (bar) {
    b();
  } else {
    c();
  }
} else {
  d();
}

to this对此

a();

if (bar) {
  b();
} else {
  c();
}

Use the Code | Unwrap/Remove使用Code | Unwrap/Remove Code | Unwrap/Remove action ( Cmd + Shift + Delete on Mac or Ctrl + Shift + Delete on Windows). Code | Unwrap/Remove操作(在 Mac 上为 Cmd + Shift + Delete或在 Windows 上为Ctrl + Shift + Delete )。 It will popup a list where you can select which surrounding structure you want to remove.它将弹出一个列表,您可以在其中 select 您要删除哪个周围的结构。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM