如何更改eclipse中的默认格式设置(change the default format settings in eclipse)

你是否厌倦了不断地重新格式化你的编程代码?只需按一下Control+Shift+F,Eclipse就会为您格式化整个文档。按照以下步骤更改Eclipse根据您个人喜好格式化文档的方式。...

步骤

  1. 1打开Eclipse程序。单击顶部工具栏中的窗口选项,然后单击首选项。
  2. Image titled Change the Default Format Settings in Eclipse Step 1
  3. 2使用框的左侧,展开Java选项,然后展开Code Style,最后单击Formatter。
  4. Image titled Change the Default Format Settings in Eclipse Step 2
  5. 3请注意,活动配置文件应设置为“Eclipse[内置]”。您无法编辑此设置,因此请单击“新建…”来创建一个新的配置文件按钮在下面。
  6. Image titled Change the Default Format Settings in Eclipse Step 3
  7. 4输入“配置文件名”。选择一个对你有意义的名字,这样你就能记住它是什么。“使用以下配置文件初始化设置”选项应该选择“Eclipse[内置]”。还应选择“立即打开编辑对话框”。现在单击“确定”创建新的格式设置。
  8. Image titled Change the Default Format Settings in Eclipse Step 4
  9. 5.您现在会看到“您选择的配置文件名称”框。共有8个选项卡,名称如下:缩进支架白色空格空白行新行控制语句行包装命令底部将有一个“应用”和“确定”按钮。您应该确保每次更改时都按“应用”按钮,这样它就会知道它肯定已保存并应用于格式设置。
  10. Image titled Change the Default Format Settings in Eclipse Step 5
  11. 6参考右边的图片查看缩进选项卡。缩进非常重要,因为如果操作得当,缩进可以使程序更具可读性。在“常规设置”区域中,可以更改选项卡的大小,您可以根据是否希望节省空间或是否希望更容易区分不同的部分来设置选项卡的大小。根据编码惯例,应该选中缩进部分中的所有框(空行框无关紧要)。别忘了点击应用。。
  12. Image titled Change the Default Format Settings in Eclipse Step 6
  13. 7单击大括号选项卡,如有必要,请参阅右侧的图片。大括号的设置相当简单,并且基于个人喜好。大多数人要么使用“同一行”或“下一行”的位置。每个选项都应该使用相同的位置。别忘了点击应用。
  14. Image titled Change the Default Format Settings in Eclipse Step 7
  15. 8单击空白选项卡。使用右边的图片作为参考。同样,这个标签是为了个人喜好和阅读方便。有许多选项可以展开、通读,然后根据您的偏好选择或取消选择要添加或删除的空间(意味着单击空格键)。不要忘记在预览窗口中查看更改,并经常单击应用,因为此选项卡中有许多选项。
  16. Image titled Change the Default Format Settings in Eclipse Step 8
  17. 单击“空白行”选项卡并使用图片作为参考。此选项卡允许您指定不同声明之前或之后的空白行数。根据选项,标准通常为0或1。如果你使用了超过一个空行,那就是在浪费空间。根据您的偏好选择选项。不要忘记选择Apply。
  18. Image titled Change the Default Format Settings in Eclipse Step 9
  19. 10查看右侧的图片,然后单击“新行”选项卡。此选项卡仅用于用户偏好,因此请根据需要选择选项。别忘了点击应用。
  20. Image titled Change the Default Format Settings in Eclipse Step 10
  21. 11“遵守控制声明”选项卡符合您的个人喜好。选择框时,请参考右侧的图片。无论是否在控制语句后添加空格,文档都很容易阅读。要限制文档的长度,请不要选中框。别忘了点击应用。
  22. Image titled Change the Default Format Settings in Eclipse Step 11
  23. 12单击“换行”选项卡,查看右侧的图片。在“线宽和缩进级别”部分中,选择文档可以有多少字符宽,以及您希望缩进的宽度,以便换行。在下面,单击每个选项,并相应地选择“换行策略”和“缩进策略”。您希望文档的包装尽可能少,以便易于阅读。不要忘记经常选择Apply,因为有很多选项。。
  24. Image titled Change the Default Format Settings in Eclipse Step 12
  25. 13在“评论”选项卡中设置选项。这是最后一个要设置的选项卡,右边的图片仅供参考。以“启用…”开头的选项应该被选中。其他选项可根据个人喜好选择。选择所有将“删除空行”的选项再次推荐。别忘了点击应用。
  26. Image titled Change the Default Format Settings in Eclipse Step 13
  27. 14查看示例程序。例如,为了向您展示格式是如何工作的,有一个示例程序(单击右侧的图片)显示了格式扭曲(即错误的缩进、额外的空格等)。
  28. Image titled Change the Default Format Settings in Eclipse Step 14
  29. 15格式化当前选定的文档。单击顶部工具栏中的Source,然后单击Format,或者作为快捷方式,您可以单击“Control+Shift+F”。
  30. Image titled Change the Default Format Settings in Eclipse Step 15
  31. 16点击右边的图片。在这里,您可以看到缩进已恢复,多余的空间已被删除,括号已根据用户的偏好放置。由于您使用了自己的个人编码风格偏好,因此您的文档不一定会像示例中那样。
  32. Image titled Change the Default Format Settings in Eclipse Step 16
  • 单击或取消单击设置时,右侧的预览屏幕将显示它对格式设置所做的更改。
  • 标签大小不应小于2。
  • 不要害怕进行更改,因为您始终可以恢复默认设置。
  • 发表于 2022-03-13 18:59
  • 阅读 ( 91 )
  • 分类:IT

你可能感兴趣的文章

初学者必备的8个eclipse键盘快捷键

... 作为一个Java程序员,您应该完全理解Java虚拟机是如何工作的,以及为什么它允许跨平台开发。您还应该熟悉核心Java概念,例如如何在Java中使用异常。你也可以用Java玩得很开心---用Java和处理技术创造出惊人的网络摄像...

  • 发布于 2021-03-11 23:36
  • 阅读 ( 362 )

为什么扫描仪使用pdf作为默认文件格式?

...F作为默认保存格式: A lot of scanning software has PDF set as the default format for newly created documents. Why is this? As I understand it, scanned documents are pixel based pictures like those in cameras. I am unaware of any cameras that store pictures using the PDF format. What does th...

  • 发布于 2021-04-08 22:55
  • 阅读 ( 143 )

能否在windows命令提示符下更改输出缓冲区的大小?

...not been filled with output yet. To change the screen buffer size from the default of 300 lines (Microsoft’s chosen default), perform the following steps: Open the Windows Command Prompt Right-click on the application’s icon in the upper left corner of the window Click on Properties in the drop...

  • 发布于 2021-04-10 02:53
  • 阅读 ( 255 )

如何将MicrosoftWord文档中的所有超链接恢复为默认的蓝色样式?

... Since there are so many hyperlinks, how can I return all of them to their default underlined blue colored text style without slowly searching through the entire document and converting each one individually? 有没有一种简单(快速)的方法可以将microsoftword文档中的所有超链接...

  • 发布于 2021-04-10 03:25
  • 阅读 ( 189 )

如何配置windows以更轻松地使用powershell脚本

...过几个路障: PowerShell does not allow external script execution by default. The ExecutionPolicy setting in PowerShell prevents execution of external scripts by default in all versi*** of Windows. In some Windows versi***, the default doesn’t allow script execution at all. We showed you how...

  • 发布于 2021-04-11 03:20
  • 阅读 ( 257 )

作用域如何影响powershell脚本

...作用域用于隔离脚本的修改。在这里,我们将探讨作用域如何影响PowerShell脚本,以及如何在它们内部和周围工作。 什么是范围(a scope)? 在PowerShell中,“scope”指的是脚本或命令shell正在运行的当前环境。作用域用于保护环境...

  • 发布于 2021-04-11 03:54
  • 阅读 ( 288 )

如何删除Windows7中的默认文件关联?

... 问题 超级用户阅读器Christothes写道: I somehow have set the default file type association for a file type in Windows 7. It doesn’t appear to be possible to delete it from the “Change the file type associated with a file extension” opti*** screen. Is it possible to remove it? 虽...

  • 发布于 2021-04-11 16:14
  • 阅读 ( 153 )

格式化时,应将分配单元大小设置为什么?

... to other drive types? Should I stop poking around and just leave it at “default?” 虽然默认设置通常是大多数用户的最佳选择,但让我们深入研究一下。 答案 超级用户贡献者Jonathan和Andrew提供了一些见解。乔纳森写道: If you are a “Standard User...

  • 发布于 2021-04-12 02:49
  • 阅读 ( 189 )

问问htg:格式化一个“看不见的”硬盘,改变android的默认应用程序,以及如何处理一个新的kindlefire

...ndroid phone and I accidently set a picture viewer I don’t want to be my default picture app, as my default picture app. Now I have no idea how to set things back! How can I wipe the default action for pictures and either switch back to the old picture viewer? Sincerely, App Stuck 亲爱的应用...

  • 发布于 2021-04-12 11:02
  • 阅读 ( 217 )

创建双引导pc或平板电脑的最佳文章

...neycomb and Ubuntu and how to install Android on your HP Touchpad with the default webOS. 双引导Galaxy标签,带蜂窝和Ubuntu 如何在HP Touchpad上安装Android 修改双引导系统 Once you set up your PC to dual boot different operating systems, the following articles show you how to ...

  • 发布于 2021-04-12 16:05
  • 阅读 ( 247 )
过路打酱油
过路打酱油

0 篇文章

相关推荐