I have a large file, about 1.5 Gb. When opening the file in vim, I typically will ctrl-c escape the buffering so I don't have to wait for the whole file to load. For one particular file, it was modified by a prepackaged program, which subsequently made it made read-only.

I needed to edit this file somewhere near the beginning, so I did so and then saved it using :wq! (as prompted to do so by vim). When I exited, I noticed that the file had decreased in size from about 1.5Gb to ~200Mb. I believe it only saved what it had loaded before I exited with :wq!.

Is this a known behavior of vim? It seems like a bad design flaw that it would tell you to exit with wq! when a file is read-only, but not warn you that it won't write what hasn't buffered yet.

2 Answers 2


Not sure what is the question here, but this is a known behaviour.
This is the reason why loading only part of the file (with ctrl-c as you did) opens the file in read-only mode, to prevent data losses like the one you described.

You can find more information here: https://stackoverflow.com/questions/908575/how-to-edit-multi-gigabyte-text-files-vim-doesnt-work


Control + C in Vim means the same as in the shell: "cancel everything you're doing as soon as possible". This includes cancelling actually reading the file

When you open a file, Vim will load it in memory ("a buffer"), and :w will write the buffer to disk. If Vim only loaded 200MB in the buffer, it will only write 200MB to disk. This is expected behaviour.

See How can I open very large files with good performance? for tips on how to improve performance.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.