如何设置 Eclipse 以在保存 JavaScript 文件时删除尾随空格?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7574340/
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
How can you set up Eclipse to remove trailing whitespace when saving a JavaScript file?
提问by bolinfest
I am running Eclipse 3.6 (Helios 20110218-0911) on Ubuntu 11.04. Under Preferences, I have gone to the following panel:
我在 Ubuntu 11.04 上运行 Eclipse 3.6 (Helios 20110218-0911)。在首选项下,我进入了以下面板:
JavaScript -> Editor -> Save Actions.
JavaScript -> 编辑器 -> 保存操作。
The "Additional actions" checkbox is checked and "Remove trailing whitespaces on all lines" is selected.
选中“其他操作”复选框并选中“删除所有行的尾随空格”。
Nevertheless, when I save my JavaScript file in Eclipse, there is still trailing whitespace at the end of my lines.
然而,当我在 Eclipse 中保存我的 JavaScript 文件时,我的行尾仍然有尾随空格。
What am I missing?
我错过了什么?
回答by atlanto
'Save Actions' for JavaScript is available in the JavaScript project(the project with JavaScript nature) only.
(If you can see 'Convert to JavaScript Project' in 'Configure' menu when right-click the project, try it)
JavaScript 的“保存操作”仅在 JavaScript 项目(具有 JavaScript 性质的项目)中可用。
(如果右键单击项目时可以在“配置”菜单中看到“转换为 JavaScript 项目”,请尝试)
回答by 0Mission0
I recently faced the same problem. The only way I found is to convert your project to Javascript project. Right click your project folder in the Explorer, choose [Configure] -> [Convert to Javascript project] and the Javascript Save Action will start to work.
我最近遇到了同样的问题。我发现的唯一方法是将您的项目转换为 Javascript 项目。在资源管理器中右键单击您的项目文件夹,选择 [配置] -> [转换为 Javascript 项目],Javascript 保存操作将开始工作。
Unfortunately, I don't know how to convert it back. Since it's not a big problem for me, the way Converting it to javascript project indeed helps me a lot.
不幸的是,我不知道如何将其转换回来。由于这对我来说不是大问题,因此将其转换为 javascript 项目的方式确实对我有很大帮助。
回答by Rudy
For the latest Eclipse - Version: Oxygen.3a Release (4.7.3a) Build id: 20180405-1200
对于最新的 Eclipse - 版本:Oxygen.3a 发行版 (4.7.3a) 构建 ID:20180405-1200
The default key-binding shift+ctrl+backspace, which binds to the function "Removes the trailing whitespace of each line" will remove trailing space chars for the entire file.
默认键绑定shift+ ctrl+backspace绑定到函数“删除每行的尾随空格”将删除整个文件的尾随空格字符。
(The key-binding shift+ctrl+backspaceis probably already there in many earlier releases as well.)
(该键绑定shift+ ctrl+backspace可能已经有很多早期版本也是如此。)