Turning off IntelliJ Auto-save

57,364

Solution 1

You can disable the recompilation by enabling Power Save Mode.

When Power Save Mode is on, IntelliJ IDEA reduces its functionality to the one of a text editor, by not executing expensive background activities that drain laptop battery. These activities include error highlighting and on-the-fly inspections, autopopup code completion , and automatic incremental background compilation.

Alternatively, or if you think this is a bit too extreme, change the update action for your Tomcat to "Do Nothing".

Solution 2

It cannot be totally disabled. It is core to the functionality of the IDE and heavily integrated into its operation, including its Open API (for plugins). Turning it off would cause problems with a lot of features.

You can disable both Save files on frame deactivation and Save files automatically if idle for x seconds settings (via File > Settings > Appearance & Behavior > System Settings):

Screenshot of synchronization settings

With those settings disabled, IDEA only auto-saves on a major event such as building, running make, running a test or application, etc. <EDIT>It should also be noted that plugin authors have access to the FileDocumentManager.saveAllDocuments() method that invokes the auto-save. This is also one more reason why removing this functionality would be problematic.</EDIT> Scrolling up in a file should not be an event to trigger auto save (unless a third party plugin is doing such). I waited a good 15 minutes to verify - no auto-save. If you are seeing different behavior, I would recommend you open up a bug report (https://youtrack.jetbrains.com). You'll want to provide as much detail as possible since IDEA 14.0.2 has been out for quite some time and there are no reports of an issue with auto-save.

Note that I have the Settings > Editor > General > Editor Tab > Mark Modified tabs with asterisk turned on to verify the file is not being auto-saved. (i.e. the asterisk remains even after a long idle period and when I reactivate the IDEA frame.) Have you turned that on? It may be something else besides auto-save that is causing the other tools to see a file change. Enabling the asterisk option would help determine that.

Why you really don't need manually saving

It should also be noted, that you always have access to Local History. Local History constantly tracks (and records) all changes made to a project. And it allows you to easily revert a file, or an entire directory, back to a previous state (even unsaved ones). So any perceived loss of functionality by not being in full control of when a file is saved is made up for with this functionality. When I first started using IntelliJ IDEA in 2003, I found the auto save functional strange and felt that I lost some control as to determine when I wanted files included in a recompile. But as I used IntelliJ IDEA, I quickly (within a week or two) came to realize that this was a false feeling of control. Between local history, changelists, and the ability to shelf changes, I ultimately had a lot more control while at the same time didn't waste time trying to figure out why my recent change was not working, only to realize I forgot to save one of the files I changed. I switch from disliking the feature to absolutely loving it. I'd encourage people that see the auto save as a "limitation" or even a "deal breaker" to just try it for a while and see. It will require some changes to your personal workflow, I think in the end you will have a better workflow. I have not missed it in the past 16+ years I've been using IDEA.

EDIT

Are you launching Tomcat via an IntelliJ IDEA run/debug configuration? If so, do you have the "on frame deactivation" option in that Run/Debug configuration set to one of the "Update" options? That would cause the files to change.

Solution 3

I think the correct answer was given as a comment from ryanlutgen above:

The beaviour of "auto-saving" your file is not due to the auto-save options mentioned.

IJ saves all changes to your build sources to automatically build the target.

This can be turned of in:

Preferences -> Build,Execution,Deployment -> Compiler -> Make project automatically.

Note: now have to initiate the project build manually (e.g. by using an appropriate key-shortcut)

(All other "auto-save" options just fine-tune the build in auto-save behaviour.)

Solution 4

The bad new is: it's not possible to disable autosaving for intellij & Co. (JetBrains Webstorm and so on). I lost some work because i pressed CTRL-Z few time to take some older code, for mistake i pressed "z" and i couldn't do anymore CTRL-Y. I cannot keep the file open in other programs because it changes all the time and the other program asks me to refresh hundred times per day...

The good new: there are some workarounds. Just see the following (the references in square brakets point to the bottom of my comment):

From the official intellij support website[1]:

«Tuning the autosave behavior

The following options are available for tuning the autosave behavior (File | Settings | Appearance and Behavior | System Settings):

Save files on frame deactivation (i.e. on switching from IntelliJ IDEA to a different application)

Save files automatically if application is idle for N seconds

Note that those are optional autosave triggers, and you cannot turn off autosave completely

Please also check the website [2] (bottom of my comment) where you can find other workarounds and more details, as the following:

«In Settings → IDE Settings → General

uncheck "Synchronize files on frame activation" → uncheck "Save files on frame deactivation"

if you can, uncheck "Save files if application is idle for". If it's greyed out, set it to 6442450 seconds (about 74 days)...»

The last is to install eclipse and choose a dark skin for it. Nothing is perfect but...

EDIT: the option described in [2] about setting a big number it's not necessary, unless something is greyed and you cannot disable the autosaving... I need to test that.

Ah... the next problem will be to find the "save" button/command. In intelliJ Ctrl+S is "Save all" ...

[1] https://www.jetbrains.com/idea/help/saving-and-reverting-changes.html#d1542336e137

[2] https://intellij-support.jetbrains.com/hc/en-us/community/posts/207054215-Disabling-autosave

Solution 5

In the latest intellij or pycharm ide use the below option for disabling autosave.

File -> Settings -> Appearance & Behavior -> System Settings -> Save files when switching to a different application(Uncheck)

enter image description here

Share:
57,364
ryanlutgen
Author by

ryanlutgen

Software Engineer with shifting responsibilities. From 2013 through mid 2015, I performed the duties of a full stack engineer utilizing AngularJS, JQuery, Jasmine, Grunt, and Java. From mid 2015 through mid 2016 I performed the duties of an internal front-end framework and dev ops engineer utilizing AngularJS, JQuery, Webpack, JSPM, Grunt, Gulp, and Gradle. Presently, I am a back-end engineer utilizing Java, Groovy, SQL, and Elasticsearch. I attempt to keep up on the latest of all of the technologies I have employed in the past, but my primary activity online, including StackOverflow, pertains to the technologies I am actively developing in professionally.

Updated on January 28, 2022

Comments

  • ryanlutgen
    ryanlutgen over 2 years

    I have done a fair amount of googling about this question and most of the threads I've found are 2+ years old, so I am wondering if anything has changed, or if there is a new method to solve the issue pertaining to this topic.

    As you might know when using IntelliJ (I use 14.0.2), it often autosaves files. For me, when making a change in Java or JavaScript files, its about 2 seconds before the changes are saved. There are options that one would think should have an effect on this, such as Settings > Appearance & Behavior > System Settings > Synchronization > Save files automatically if application is idle for X sec. These settings seem to have no effect for me though, and IntelliJ still autosaves, for example if I need to scroll up to remember how a method I am referencing does something.

    This is really frustrating when I have auto-makes, which mess up TomCat, or watches on files via Grunt, Karma, etc when doing JS development. Is there a magic setting that they've put in recently? Has anyone figured out how to turn off auto-save, or actually delay it?

  • ryanlutgen
    ryanlutgen about 9 years
    While that setting was disabling too much for me, it did lead me to what I was looking for. File > Settings > Build, Execution, Deployment > Compiler. Uncheck Make Project Automatically when doing JS development. Thanks!
  • ryanlutgen
    ryanlutgen about 9 years
    I have the two settings turned off in your image and I have the asterisk on dirty preference on. The issue for me appears to be that when intelliJ does auto-makes, it iterates through JS files and saves them, even though they are not relevant. I will plan on submitting a ticket on the link you provided. Thanks!
  • Levon
    Levon almost 8 years
    This inability to control when and how often my files are saved is a total deal breaker - too bad, there's much to like about IntelliJ/PyCharm.
  • Levon
    Levon almost 8 years
    Thanks for confirming what I suspected. Too bad, I would like to control when and how often my files - this is a total deal breaker with regard to IntelliJ/PyCharm. I know there's a history I can use to undo the various saves - but add extra steps to undo what I don't want done in the first place?
  • fresko
    fresko almost 8 years
    The worst is when you do CTRL-Z and you discovery that the history is not so long as you expected, and you cannot go back to your last working-version of the file. Disabling autosave, you need to know that when you CLOSE the program, it will... SAVE ALL... without asking (are you sure you didn't press a key and overwrote selected text, or added a char that made the code to don't work?). Perosnally, Eclipse is better for that, and in addition, it has a better search function.
  • Levon
    Levon almost 8 years
    Agreed. I've been using Eclipse with PyDev, now I'm trying out WingIDE. I just can't wrap my head around why IntelliJ/PyCharm does this totally counter-intuitive thing. And as you point out, even ^S doesn't save the current file (like it does in other applications) but saves ALL files .. ugh.
  • Pieter De Bie
    Pieter De Bie over 7 years
    Intellij has a local history that only clears when you install a new version or invalidate caches. So I don't really get the CTRL+Z problem
  • Harish
    Harish over 5 years
    This is still a problem in 2018 (and in future) IMO. Although workarounds are good, but I don't like workarounds to not save my bad codes accidentally. It should be the core functionality like MS tools where nothing gets saved until you actually hit ctrl+s.
  • fresko
    fresko over 5 years
    There is eclipse, it's for free and behaves well, for example when renaming variables or when you leave the mouse on a function and the Javadoc appears. But people don't appreciate what's for free, there are lots of users on forums telling that IntelliJ is better and then everybody get convinced by them without wondering if tehre is a real reason for that...
  • redfox05
    redfox05 about 5 years
    Has this functionality been removed? In 2019 now, and can't find the Compiler option under 'Build, Execution, Deployment'