What is Sublime Text doing when I save a file?
Solution 1:
Sublime Text 3 (which I assume you're using) uses atomic saves by default (it can be disabled by setting "atomic_save": false
in your user settings), which means it creates temp files and then overwrites the original file (and deletes the temp file) on save. See this thread on the Sublime forums for a little more info, especially the reply from jps
(Sublime's author) on its disadvantages.
Basically, atomic saving is useful because if anything were to happen during saving you (theoretically) shouldn't end up with a corrupted original file. Downsides include potential loss of file metadata (although Sublime uses native OS X and Windows APIs to prevent that), unexpected behavior in directories with nonstandard permissions (for example, they allow modification of existing files, but not the creation of new ones), and issues when saving to some network drives or services like Dropbox, which I've experienced personally.
EDIT
Since I originally answered this, I've come across a number of questions where post-save file-watching compilers/preprocessors like LESS/SASS/SCSS, Guard, etc. were not doing their thing because the original file they were watching had been deleted by atomic saving, then created again, but they weren't watching it any more. It can also severely affect file I/O speed when working with network filesystems, SSHFS in particular. It's a good idea in theory, but it can wreak havoc if you don't know it's there or what it's doing, so if you'll be doing any kind of work on networked/shared/watched files, it's probably best just to turn it off. Just go to Preferences -> Settings-User
and add this line
"atomic_save": false
to the end (the file has to be valid JSON, so make sure there's a comma ,
after the previous line). Save, and you're good to go!
UPDATE
As of Sublime Text 3 Build 3072, atomic_save
is now disabled by default! If you are a registered user, you can download the latest development build here. This feature has not been ported to the public beta (currently Build 3065), but hopefully a new version will be released soon. As of Feb/March 2015, Sublime's development pace has picked up substantially, with a number of new features having been added. Once the bugs have been worked out of them, a new public version should be forthcoming.
update to the UPDATE
"atomic_save": false
is (as of March 2015) now in the default settings from Build 3080 and higher.
Solution 2:
If it is related to name.php file,and after saving you are getting another name.php-tmp file, then you can remove PHPTools package From Preference ->Browse Packages, It will be rectified.