Ming Lei wrote: > I have a basic question about vim internal. Let me use an example to > describe: > > Say I have a text file of 20Mbytes. I use VIM to insert 3 characters at > offset 1024 bytes from the beginning of the file and then I save the > file. My question is: how does VIM handle the file write and save? Does > VIM rewrite the whole file back to disk/file system? Can anyone describe > the procedure that VIM employs at the granularity of the system call?
Vim always writes the whole file. Most systems allow overwriting halfway a file, but inserting halfway a file is rare (I can't name a system that supports this). Anyway, Vim wants to keep the original file so long as writing isn't finished, to avoid the risk that a system crash results in neither the original or the new file. -- Nobody will ever need more than 640 kB RAM. -- Bill Gates, 1983 Windows 98 requires 16 MB RAM. -- Bill Gates, 1999 Logical conclusion: Nobody will ever need Windows 98. /// Bram Moolenaar -- [EMAIL PROTECTED] -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ download, build and distribute -- http://www.A-A-P.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///