97

I would like Eclipse to automatically save every time I edit a file, in much the same way that it builds automatically. Because I've been using IntelliJ for the last year (which saves automatically by default), I keep having the following problem:

  • Make some changes in Eclipse
  • Forget to press save
  • Run the build, unit tests, and notice some strange behaviour
  • (Some time later....) realize that the unexpected behaviour occurred because I forgot to save the changes

Is there any way I can make Eclipse save automatically?

UmAnusorn
  • 10,420
  • 10
  • 72
  • 100
Dónal
  • 185,044
  • 174
  • 569
  • 824
  • 2
    I would recommend against using auto-save plugins. The reason is that a save will always cause an incremental build. If you are using Java only, this is not problem. But, when you start using other languages, like AspectJ, Groovy, or even non-compiled languages like JavaScript, incremental builds can be much longer. This is because a change in a single file can cause a much longer build (since dependency graphs between files tend to be denser). I would recommend using the "Save automatically" option instead of the autosave plugins. – Andrew Eisenberg Jun 17 '13 at 17:23
  • 1
    No need to install more plugin. please look at my answer below – UmAnusorn Oct 10 '16 at 11:35

8 Answers8

117

Eclipse Neon (4.6)

Window > Preferences

Window Preferences

General > Editors > Autosave > check Enable autosave for dirty editors > choose the value for autosave interval (in seconds)

General Editors Autosave

Details in M7:

Auto-save of dirty editors is now available in Eclipse. 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, ...).

ROMANIA_engineer
  • 54,432
  • 29
  • 203
  • 199
33

You can go here and check the box Save automatically before build

Windows > Preferences > General -> Workspace

GuruKulki
  • 25,776
  • 50
  • 140
  • 201
20

First, try Window -> Preferences -> General -> Workspace. There you can check "Save automatically before build" and "Build automatically."

If that does not work,

PLEASE TRY

Preferences -> Run/Debug -> Launching -> "Save dirty editors before launching"

UmAnusorn
  • 10,420
  • 10
  • 72
  • 100
19

You can do it with the saveDirtyEditor plugin as referenced in this question/answer. There is no non-plugin way of doing it.

Community
  • 1
  • 1
Nick Fortescue
  • 43,045
  • 26
  • 106
  • 134
18

I wrote an Eclipse plugin for this called smartsave. It's available in the Eclipse Market Place.

It saves your files at a specified interval and you can even tune it to prevent saving if errors, or warnings, are present in the preferences dialog.

mystilleef
  • 181
  • 1
  • 5
  • 1
    Hey, nice plugin. It would really be cool if you could filter which tiles (by extension) are saved automatically. For instance, I want to save .txt files, but not .xml files. – Lincoln May 01 '13 at 15:10
  • It doesn't work on Eclipse 4.5.1, It doesn't show up in Preferences. Please fix. – wesamly Jan 12 '16 at 19:18
  • FYI: if formatter is configured to run when a file is saved, it does trigger the formatter when it saves. yay. – simpleuser Mar 10 '16 at 23:20
  • A very nice feature (which I use in MATLAB) is to save file when the file looses focus, mostly on tab switch. This proved to be very effective as it seems that we mostly need files to be saved when we switch to other file. – Danijel Jun 19 '20 at 09:25
7

In Helios this can be done by going to preferences and setting:

Run/Debug > Launching > Save required dirty editors before launching

AnthonyW
  • 1,910
  • 5
  • 25
  • 46
0

For Eclipse Mars 2, the settings are below Window > Preferences > General > Workspace. These settings are in minutes and not in seconds.

enter image description here

Tatkal
  • 568
  • 4
  • 9
  • 29
0

You could go to Windows > Preferences > Autosave and set the auto intervals to 1.

rbento
  • 9,919
  • 3
  • 61
  • 61
Jasbin karki
  • 127
  • 2
  • 8