eclipse 删除源代码中的缩进

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6323199/
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-09-19 16:26:28  来源:igfitidea点击:

remove indentation in source code

javaeclipsewindowbuilder

提问by BILL

I use Eclipse IDE and Window Builder Pro for create window. When I go to the source code I see a big indent text. How to delete ? See

我使用 Eclipse IDE 和 Window Builder Pro 来创建窗口。当我转到源代码时,我看到一个很大的缩进文本。如何删除? 看

回答by vemv

How about good old Shift + Tab?

旧的 Shift + Tab 怎么样?

回答by Swaranga Sarma

If by "how to delete"you mean to say that you want to decrease the indentation level, try this:

如果“如何删除”是说要降低缩进级别,请尝试以下操作:

Go to

Window->Preferences->general->Editors->Text Editors

窗口->首选项->常规->编辑器->文本编辑器

There specify the indentation level under :

在 下指定缩进级别:

Displayed Tab Width.

显示的标签宽度。

Additionally you can customize you formatting in Eclipse as :

此外,您可以将 Eclipse 中的格式自定义为:

Go to

Window->Preferences->Java->Code Style->Formatter

窗口->首选项->Java->代码样式->格式化程序

Select the formatter and press Edit. Use whatever suits you.

选择格式化程序并按Edit。使用适合您的任何东西。

Then Select the text you want to format and press Ctrl+Shift+F

然后选择要格式化的文本并按 Ctrl+Shift+F

回答by KrzyH

If you want to fix indent only you can select lines and press Ctrl-I. Take a look at Eclipse keys

如果您只想修复缩进,您可以选择行并按Ctrl-I。看一下Eclipse 键

回答by Atreys

If you like the way your formatter is set up for the rest of your code, perhaps telling the formatter not to work on this sectionwould be desirable. Then you can unindent the section to make it visually appealing and not worry about it changing formatting.

如果您喜欢为其余代​​码设置格式化程序的方式,也许告诉格式化程序不要在此部分工作是可取的。然后,您可以取消该部分的缩进以使其具有视觉吸引力,而不必担心它会更改格式。

Linked solution works in Eclipse 3.6.

链接解决方案适用于 Eclipse 3.6。

回答by Alex Gitelman

Most likely you insert tab character which is being expanded to 8 positions in target IDE. Change setting in Eclipse to insert 4 spaces (or whatever your style is) when tab is pressed. Then you can try to reformat your file in Eclipse. Also, you can use sed to replace \twith 4 spaces.

很可能您插入了在目标 IDE 中扩展到 8 个位置的制表符。更改 Eclipse 中的设置以在按下 Tab 键时插入 4 个空格(或任何您的风格)。然后您可以尝试在 Eclipse 中重新格式化您的文件。此外,您可以使用 sed 替换\t为 4 个空格。