Java 是否可以在 1 秒内自动缩进 NetBeans 中的代码?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19094465/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-12 14:02:46  来源:igfitidea点击:

Is it possible to autoindent code in NetBeans in 1 second?

javanetbeansindentationauto-indent

提问by user1111261

I have this code:

我有这个代码:

static int kontrolaParityZavorek2(final char[] text, int zacatek) {
while (zacatek < text.length && jeOteviraciZavorka(text[zacatek])) {
int konec = kontrolaParityZavorek2(text, zacatek + 1);
if (konec >= text.length ||!jsouParove(text[zacatek], text[konec])) 
{throw new RuntimeException("Chybi uzaviraci zavorka na pozici: " + konec);}
zacatek = konec + 1;
}
return zacatek; 
}

I want to go to NetBeans, paste this code and autoindent the code in 1 second, so that it looks like this:

我想转到 NetBeans,粘贴此代码并在 1 秒内自动缩进代码,使其看起来像这样:

static int kontrolaParityZavorek2(final char[] text, int zacatek) {
  while (zacatek < text.length && jeOteviraciZavorka(text[zacatek])) {
    int konec = kontrolaParityZavorek2(text, zacatek + 1);
    if (konec >= text.length ||!jsouParove(text[zacatek], text[konec])) 
    {throw new RuntimeException("Chybi uzaviraci zavorka na pozici: " + konec);}
    zacatek = konec + 1;
  }
  return zacatek; 
}

Is it possible? If so, which key combination should I use or where in MENU can I find the function of AUTO INDENTING.

是否可以?如果是这样,我应该使用哪个组合键或在 MENU 中的哪个位置可以找到 AUTO INDENTING 的功能。

回答by Jeroen Vannevel

Use the auto-formatter.

使用自动格式化程序。

Source -> Format

来源 -> 格式

or

或者

Alt + Shift + F

Alt + Shift + F