Decrease chances of file corruption in case of computer crash
From Vim Tips Wiki
Tip 1507 Previous Next Created: June 10, 2007 Complexity: intermediate Author: Yakov Lerner Version: 6.0
Bad luck happens.
On the Vim mailing list, one user complained about irrepairable file corruption that happened after OS crash and reboot. The filesystem repair utility, fsck, dutily repaired the filesystem at the expense of losing large pieces of data from his file. Yick. Recently changed files suffer most danger if OS crashes.
The following autocommand will decrease chances of file loss in case of unexpected hardware failure or unexpected electricity failure:
" disk sync after every write au BufWritePost * silent !sync
May uninterrupted power be with you.
