IntelliJ IDEA reload file from disk on type - intellij-idea

I have used Emacs a lot, and in Emacs when you try to edit a file which has been modified on disk, it disallows it, prompts that the file has changed, and asks you what you want to do about it.
In IntelliJ, if a file has changed on disk, I can type forever. This just happened to me: I wrote a 20 line function, and tried to save. Then IntelliJ prompted that the file had changed. I had the option of overriding my changes with the data on disk, or to corrupt the whole file by keeping the current data. I wanted to just copy my function and reload, but I couldn't even do that because the popup had the focus. I there isn't even a button to cancel the save. I pressed Escape and prayed that my change would be overwritten. What a nightmare...
Is there any way to make IntelliJ prompt on the first character typed? I really don't want to synchronize the whole project every time I start to edit a file a switch git branch.

Preferences > Appearance & Behavior > System Settings
Under the heading 'Synchronization', enable the property 'Synchronize files on frame or editor tab activation'.

Related

IntelliJ IDEA 2016.3.4 is autosaving my files every 1 second

I know one great feature of Intellij IDEA is saving your work automatically. But I have a Bug with that feature. No matter what setting I choose if I disable Save files automatically if application is idle for N seconds and Save files on frame deactivation or if i enter 15s idle time before autosaving my files get saved instantly when editing them.
The annoying on this bug is, that I let cut all tailing white-spaces when saving a file. So when i edit a file all indention of the new line gets removed cause of autosaving.
So my Question are there anywhere else options to set autosaving?
EDIT: After switching to an other project I didn't recognized this behavior. So there must definitely some setting in the Project-setting which overrides the Option Save files automatically if application is idle for N seconds.
This can happen if you have a File Watcher with the Immediate file synchronization option enabled.
Another possible case is the Build project automatically option enabled. This will save and compile the changes on the fly to report any errors from the compiler and to ensure fast running so that you don't have to wait for the compilation before run.
There is an open issue for always autosaving pom.xml files. If it's the case, vote for it:
IDEA-63462 Autosave should be turned off / massively delayed for pom.xml files

How to detect file changed by myself in IntelliJ IDEA

Is it possible in Intellij to mark edited file tabs with a star (*) so that I can see which files I have changed.
By default, Intellij automatically saves your edits every few seconds, and every time it looses focus. So, most of the time your files are not in a changed state, so no icon is needed. However, under Settings, IDE Settings, Editor, Editor Tabs, there is an option to Mark modified tabs with asterisk, which will enable the feature you want.

In Intellij IDEA how do I reload file content's from disk?

In vim I can type :e and reload a file's contents from disk overwriting any changes I've made. It's a nice way to reset in case I've gotten lost or just want to undo all my changes. This obviously doesn't take into account any kind of refactoring, I just want to nuke all changes to buffer. Not even closing and reopening a tab will work.
How do I do this with Intellij IDEA? I'm using Intellij IDEA Ultimate 13 and I've disabled any kind of auto save.
File > Synchronize (Ctrl+Alt+Y)
It will load the file from the file system. If you have unsaved changes, it will ask if you want to discard them.
⌥⌘Y - Synchronize for Mac users
What I do in a similar situation:
Simple - Ctrl+Z, Ctrl+Shift+Z many times to quickly navigate the editing history
VCS rollback - either for the whole file or for the area being edited (by clicking green areas on the left)
Local History. Well, yes, for you case it's granularity is not sufficient, so first might be an option
There is also an option to put a label into Local History if you need to rollback to a specific point in time.
For those who use autosave - it is being triggered when code editor loses focus. So doing Alt-Tab during long editing without compiling or running the code makes sense.
Open the file in another editor, make an insignificant change and save it. PHPStorm will ask you what to do because the file system and in memory copies of the file have diverged. Click "Load File System Changes".
Note, I was unable to use my undo history as it had become corrupt.
Since what I want isn't really possible I wrote an extension to do it for me:
https://github.com/btipling/DiskRead/
I'll add it to the Jetbrains plugin repository, it's called "DiskRead".
I wrote a blog post about how I created this if anyone is curious.

IntelliJ - not asking if I want to save a file

I'm new to the IntelliJ IDE. In the past I was working with Visual Studio or Eclipse.
In those IDEs there was an asterisk * above the name of the file which has been modified.
But in IntelliJ with the default configuration I can't see if the file is modified. What's more the file is saved automatically when I change focus to another window.
I've found some options under Settings -> IDE Settings -> General -> Synchronization:
Synchronize files on frame activation
Save files on frame deactivation
Save files automatically if application is idle for...
After unchecking all that options the file is not saved automatically every time I change focus to another window, which is good. But still I can't:
see if the file is modified (no asterisk)
decide if the file should be saved when I'm closing it (IDE doesn't ask for that)
And when I'm closing IntelliJ file which has been modified is saved without even noticing.
Do you know what can I do to change how IntelliJ behaves?
After unchecking mentioned options go to:
Settings/Editor(IDE Settings)/Editor Tabs:
Check "Mark modified tabs with asterisk"
On 2019.3 Ultimate it's under:
Settings/Editor/General/Editor Tabs:
Mark modified (*)
The exact Save feature like eclipse is not available in IntelliJ.
Because IntelliJ IDEA has the ability to change so many files
simultaneously in large refactoring actions, and change them without
ever opening them, single file saves don't make very much sense. In
recognition of this, IntelliJ IDEA reserves the right to save any of
your files literally whenever it wishes. It's actually quite nice to
never have to worry about your file's save statuses, once you get used
to it.
"What if I don't like some changes I made, and want to roll them
back?", I hear you say. Well, for that IntelliJ IDEA includes this
amazing feature called the Local History. Every time it saves your
files, IntelliJ IDEA actually saves a diff of your file from it's
previous state, and saves that as well. You can see the entire edit
history of your files (going back some number of days), see the
changes you've made, and roll back any change. It rules triumphantly,
and more than makes up for the temporary disorientation caused by lack
of single-file save.
https://intellij-support.jetbrains.com/hc/en-us/community/posts/206336279/comments/207351939
To show an asterisk when a file is modified: open Settings (CTRL+ALT+S), switch to Editor > General > Editor Tabs and select the Mark modified tab with asterisk checkbox.
To remove autosave, uncheck: Appearance & Behavior > System Settings > Save files on frame deactivation

MATLAB hangs when saving workspace

I'm using MATLAB R2012a with a dual-screen setup, so I have the command window on one screen and the M-file editor on the other. Sometimes when I make changes to my source code, I'll accidentally press Ctrl+S while the command window is in focus (instead of the editor). This loads a file chooser dialog for saving a MAT file of the workspace. However, regardless of whether I press "Cancel" or "OK", MATLAB hangs indefinitely. Is there something I can do so that saving the workspace doesn't fail?
I don't really care about being able to save the workspace, I just need it to work so that MATLAB doesn't hang whenever I accidentally try to.
As a temporary fix, you can un-define the Ctrl+S shortcut to save the workspace from the settings.
Go to File > Preferences > Keyboard > shortcuts: