如何自动删除Eclipse中的尾随空格? [英] How to auto-remove trailing whitespace in Eclipse?

查看:498
本文介绍了如何自动删除Eclipse中的尾随空格?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个问题有两个部分,其中一个我已经有了答案。

The question has two parts, one of which I already have the answer for.


  1. 如何自动删除尾随空格正在编辑的整个文件中? - >答案:使用 AnyEdit插件,可以将其保存到文件中

  2. 如何仅从我更改的行自动删除尾随空格 ? - >这个我不知道,不会感谢任何帮助。

  1. How to auto-remove trailing whitespace from the entire file being edited? -> Answer: use the AnyEdit plugin, which can be set to do that on any save to the file.
  2. How to auto-remove trailing whitespace only from the lines I changed? -> This I don't know and would appreciate any help.


推荐答案


  1. 从正在编辑的整个文件中删除空格

  1. Removing whitespace from the entire file being edited:

> - > Java - > 编辑器 - > 保存操作 - >检查执行保存选择的操作 - >检查其他操作 - >单击配置.. - >转到代码组织选项卡 - >检查删除尾随空格 - >选择所有行

Preferences -> Java -> Editors -> Save Actions -> check Perform the selected actions on save -> check Additional actions -> click Configure.. -> go to Code organizing tab -> check Remove trailing whitespace -> select All lines.


  1. 仅从行I中删除空格更改

  1. Removing whitespace only from the lines I changed:

首选项 - > Java - > kbd>编辑器 - > 保存操作 - >检查执行保存选择的操作 - >检查格式化源代码 - >选择格式化编辑的行

Preferences -> Java -> Editor -> Save Actions -> check "Perform the selected actions on save -> check Format source code -> select Format edited lines.

请注意,不必单击配置格式化程序格式化程序页面上的设置 - 所有代码样式自动包括删除尾随空格。至少我在Formatter配置中找不到一个设置,它是内置的Java约定,Eclipse,Eclipse 2.1样式以及 GoogleStyle

Note it is not necessary to click Configure the formatter settings on the Formatter page - all the code styles automatically include removing trailing whitespace. At least I couldn't find a setting for this in Formatter configuration, and it worked out of the box for built-in Java Conventions, Eclipse, Eclipse 2.1 styles, as well as GoogleStyle.

使用这个设置,你显然还需要关闭解决问题的第1部分。

When using this set-up, you obviously need to also turn off the solution to part 1 of the question.

Eclipse version checked: 4.5.2

这篇关于如何自动删除Eclipse中的尾随空格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆