简体   繁体   English

代码自动完成后禁用 Intellij IDEA 追加空间

[英]Disable Intellij IDEA append space after code autocomplete

An example: When I want to type public , I type pub and press tab , IDEA automatically append a space after public , how can I turn off it.一个例子:当我想输入public ,我输入pub并按tab ,IDEA 自动在public后面附加一个空格,我该如何关闭它。

Because I am used to tapping space after autocompletion, so every time after that, there are 2 spaces and I have to delete one.因为我习惯了自动补全后敲空格,所以之后每次都是2个空格就得删一个。 Other IDEs or text editors I've used seem not to append that space automatically.我使用过的其他 IDE 或文本编辑器似乎不会自动附加该空间

You cannot disable this particular piece of autocomplete behavior in IDEA short of disabling autocompletion feature altogether.你不能在 IDEA 中禁用这个特定的自动完成行为,除非完全禁用自动完成功能。

You can, however, use the 'Reformat' action to apply single default format to your whole file ( Ctrl+Alt+L ) or 'Complete Current Statement' action after you are done typing a construct (highlight the statement and press Ctrl+Shift+Enter ).但是,您可以使用“重新格式化”操作将单一默认格式应用于整个文件 ( Ctrl+Alt+L ) 或“完成当前语句”操作在完成输入构造后(突出显示该语句并按Ctrl+Shift+Enter )。 Conformed to the default formatting settings, double spaces should be replaced with single ones.符合默认格式设置,双空格应替换为单个空格。


Assuming that this is for Java code (although the general mechanism is true for most file types), you can modify when/how spaces are used in code.假设这是针对 Java 代码的(尽管一般机制适用于大多数文件类型),您可以修改代码中空格的使用时间/方式。

Go to File |转到文件 | Settings |设置 | Code Style |代码风格 | Java .爪哇

If you then click on the Spaces tab you can specify the code layout you want.如果然后单击 Spaces 选项卡,则可以指定所需的代码布局。 After you've done this if you reformat your code it should format according to your preferences.完成此操作后,如果您重新格式化代码,它应该根据您的偏好进行格式化。

You can specify this for other types too (General, CSS, JavaScript and so on).您也可以为其他类型(General、CSS、JavaScript 等)指定此项。

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

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