codecamp

IntelliJ IDEA使用语言构造的周围代码块

IntelliJ IDEA 具有语言构造的代码块

适用的上下文

环绕功能:代码 |使用 "Surround with" (Code | Surround with)或 "Ctrl + Alt + T" 可以将表达式或语句放在块或语言构造中。IntelliJ IDEA 中的此功能适用于:

上下文Surround with
示例
Java 语句
  • if
  • if/else
  • while
  • do/while
  • for
  • try/catch
  • try/finally
  • try/catch/finally
  • synchronized
  • Runnable
  • {}
IntelliJ IDEA使用语言构造的周围代码块
Java 表达式
  • (expr)
  • ((Type)expr)
  • !(expr instanseof Type)
IntelliJ IDEA使用语言构造的周围代码块
XML / HTML / JSP / JSPX 标签
  • 标签
  • CDATA 部分
  • <%...%>
  • Emmet
IntelliJ IDEA使用语言构造的周围代码块
JavaScript 语句
  • (expr)
  • !(expr)
  • if
  • if / else
  • while
  • do / while
  • for
  • try / catch
  • try / finally
  • try / catch / finally
  • with
  • function
  • { }
  • function expressi
IntelliJ IDEA使用语言构造的周围代码块
ActionScript 语句
  • if
  • if / else
  • while
  • do / while
  • for
  • try / catch
  • try / finally
  • try / catch / finally
  • with
  • function
  • {}
  • function expression
IntelliJ IDEA使用语言构造的周围代码块
PHP 语句
  • if
  • if / else
  • while
  • do / while
  • for
  • foreach
  • try / catch
  • function
IntelliJ IDEA使用语言构造的周围代码块
自定义折叠区域评论代码的任何片段,其中 Surround With 是适用的
IntelliJ IDEA使用语言构造的周围代码块

IntelliJ IDEA 周围的代码块

围绕一个代码块

  1. 选择所需的代码片段。
  2. 执行以下操作之一:
    • 在主菜单上选择代码| Surround With(Code | Surround With)
    • 按 Ctrl+Alt+T。

    弹出窗口根据上下文显示包围语句的列表。

  3. 从列表中选择所需的环绕语句。为此,请使用鼠标光标,上下箭头键或列表中每个元素旁边显示的快捷键。
IntelliJ IDEA使用排列规则重新排列代码
IntelliJ IDEA语句的删除与括号的配置
温馨提示
下载编程狮App,免费阅读超1000+编程语言教程
取消
确定
目录

IntelliJ IDEA的一般准则

什么是IntelliJ IDEA项目

使用IntelliJ IDEA的意图行为

IntelliJ IDEA使用运行/调试配置

特定于VCS的程序

IntelliJ IDEA语言和特定框架指南

IntelliJ IDEA的数据库和SQL功能

IntelliJ IDEA使用之JavaServer Faces(JSF)

IntelliJ IDEA:分析PHP应用程序的性能

IntelliJ IDEA:调试PHP应用程序

IntelliJ IDEA:适用于PHP的Google App Engine

IntelliJ IDEA更多内容

关闭

MIP.setData({ 'pageTheme' : getCookie('pageTheme') || {'day':true, 'night':false}, 'pageFontSize' : getCookie('pageFontSize') || 20 }); MIP.watch('pageTheme', function(newValue){ setCookie('pageTheme', JSON.stringify(newValue)) }); MIP.watch('pageFontSize', function(newValue){ setCookie('pageFontSize', newValue) }); function setCookie(name, value){ var days = 1; var exp = new Date(); exp.setTime(exp.getTime() + days*24*60*60*1000); document.cookie = name + '=' + value + ';expires=' + exp.toUTCString(); } function getCookie(name){ var reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)'); return document.cookie.match(reg) ? JSON.parse(document.cookie.match(reg)[2]) : null; }