Atomic Save : Save files atomically with ordinary "w" command
| script karma
Downloaded by 206
Comments, bugs, improvements
script versions (upload new version)
|This is an atomic save function for vim. IOW, this is an atomic write ('w') function for vim. It makes sure that there is always a fully-written copy of the file in place to be read by other programs. It uses the system 'mv' since vim's rename() function removes the destination file rather than atomically replacing it.
To use it, you enable it as described below, and then 'w' your file like normal.
NOTE: if using windows, see the note below.
|Put the function in your .vimrc, also after that, add this line to save all files atomically:
autocmd BufWriteCmd * call AtomicSave()
Or add a line like this, which will only save files named ".procmailrc" atomically:
autocmd BufWriteCmd .procmailrc call AtomicSave()
Type :help autocmd for more info on how you can choose when to use this function
NOTE: If you are using windows, you probably need to change "mv" to "rename" -- unless you have installed GNU coreutils deep in the bowels of your microsoft OS.
Click on the package to download.
ip used for rating: 18.104.22.168
||This version will preserve file permissions on the saved file using GNU chmod. If your system does not have GNU chmod, it will fail.
Another change: it will now produce a status message indicating success, after writing the file.