如何配置 eclipse 以在运行时自动保存?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1142547/
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 to configure eclipse to autosave on run?
提问by IAdapter
I'm looking for a configuration or plugin for eclipse that automatically saves files (so I don't have to use Ctrl+S). It could do it on lost focus or over some period of time. I think I saw something like that (I know IDEA has it), but I cant find it now.
我正在寻找自动保存文件的 Eclipse 配置或插件(所以我不必使用 Ctrl+S)。它可以在失去焦点或在一段时间内完成。我想我看到了类似的东西(我知道 IDEA 有),但我现在找不到了。
回答by VonC
Update seven years later (Eclipse Neon 4.6)
七年后更新(Eclipse Neon 4.6)
Eclipse now has an Automatic Save of dirty editors
The autosave option is disabled by default.
A new autosave preference page (Preferences > General > Editors > Autosave
) is available and allows to enable/disable the autosave and change the interval of autosave.
The countdown is reset on keyboard activity, mouse click, or when a popup is displayed (e.g. content assist, preference page, ...).
默认情况下禁用自动保存选项。
新的自动保存首选项页面 (Preferences > General > Editors > Autosave
) 可用,允许启用/禁用自动保存和更改自动保存的间隔。
倒计时在键盘活动、鼠标单击或显示弹出窗口时重置(例如,内容辅助、首选项页面等)。
Original answer (2009)
原始答案 (2009)
The OP IAdapteradded in the comments:
该OP IADAPTER添加的评论:
I bet plugin like I describe exists.
我打赌像我描述的插件存在。
... and you are right!
......你是对的!
Eclipse plugin saveDirtyEditorshould do just what you need.
Copy the SaveDirtyEditors_1.0.2.jar
in your plugin directory.
Eclipse 插件saveDirtyEditor应该可以满足您的需求。
将 复制到SaveDirtyEditors_1.0.2.jar
您的插件目录中。
You will get a new preference page under
您将在下面看到一个新的首选项页面
General > Editors > Text Editors > Save Dirty Editors
, allowing you to save dirty files like 'myfile.java
' under 'myfile.java.snapshot
' every 30 seconds (can be less if you want).
,允许您每 30 秒保存一次像 ' myfile.java
' 下的 ' myfile.java.snapshot
'脏文件(如果需要,可以更少)。
Without additional plugin, though, Eclipse does not support natively that feature.
但是,如果没有额外的插件,Eclipse 本身不支持该功能。
The closest could be:
最接近的可能是:
Window > Preferences > type "build"
> General > Workspace > [x] Save automatically before build
That way, each time you hit CTRL+Bfor actually building your sources, they would be saved.
But I realize this is not exactlywhat you are after.
Beware your option would not be very efficient with the "build automatically" option activated... (that would trigger too much builds)
这样,每次您按CTRL+B实际构建源时,它们都会被保存。
但我知道这不是正是你所追求的。
请注意,激活“自动构建”选项后,您的选项将不会非常有效......(这会触发太多构建)
Again, without achieving exactly what you are looking for, you also have:
同样,在没有完全实现您正在寻找的东西的情况下,您还拥有:
Run/Debug > Launching > Save required dirty editors before launching
Run/Debug > Launching > [x] Build (if required) before launching
Note: the difference between IntelliJ IDEA and eclipse is the "compile on save" feature:
注意:IntelliJ IDEA 和 eclipse 的区别在于“保存时编译”功能:
As mentioned in the IDEA FAQ:
Q:
Can I enable "compile on save" in IntelliJ IDEA?IntelliJ IDEA currently doesn't support this feature.
However there is an "Eclipse-mode" plug-in which provides similar functionality, so we suggest you to try this plug-in.
Note that by default IntelliJ IDEA saves the files for you, so you don't have to press the Ctrl+S shortcut frequently like you need to do in other IDEs.
问:
我可以在 IntelliJ IDEA 中启用“保存时编译”吗?IntelliJ IDEA 目前不支持此功能。
但是有一个“ Eclipse-mode”插件提供了类似的功能,所以我们建议你试试这个插件。
请注意,默认情况下 IntelliJ IDEA 会为您保存文件,因此您不必像在其他 IDE 中那样频繁地按 Ctrl+S 快捷键。
However, with Eclipse, the "build on save" is activated by default, hence the absence of that particular feature.
但是,对于 Eclipse,默认情况下会激活“在保存时构建”,因此没有该特定功能。
回答by ponty
http://code.google.com/p/eclatosa/
http://code.google.com/p/eclatosa/
"Saves all open editors in eclipse when deactivating the eclipse window (like in IntelliJ)"
“当停用 Eclipse 窗口时,在 Eclipse 中保存所有打开的编辑器(如在 IntelliJ 中)”
回答by UmAnusorn
No need to install more plugin.
无需安装更多插件。
Window -> Preferences -> General -> Workspaceand there you can check:
Window -> Preferences -> General -> Workspace然后你可以检查:
Save automatically before build + Build automatically
If that doesn't work try this:
如果这不起作用试试这个:
Preferences -> Run/Debug -> Launching -> Save dirty editors before launching
首选项 -> 运行/调试 -> 启动 -> 启动前保存脏编辑器
回答by Rahul
Try this
尝试这个
Goto Eclipse Preferences > General > Editors > Autosave
转到 Eclipse首选项 > 常规 > 编辑器 > 自动保存
if it not work then try this
如果它不起作用,那么试试这个
Preferences -> Run/Debug -> Launching -> Save dirty editors before launching
首选项 -> 运行/调试 -> 启动 -> 启动前保存脏编辑器
回答by Channing Walton
I wrote a plugin a long time ago to do this that still seems to work: http://www.stateofflow.com/projects/71/save-me
我很久以前写了一个插件来做到这一点,但似乎仍然有效:http: //www.stateofflow.com/projects/71/save-me
It saves the editor when it loses focus. However, if you switch away from eclipse it doesn't notice.
它在失去焦点时保存编辑器。但是,如果您从 eclipse 切换,它不会注意到。