Why can’t Vim open a 100 MB text file when I have 16 GB RAM

memoryvim

I have a 100MB MySQL database backup file and I have trouble to open it in Vim on my Linux box that has 16G of RAM.

Vim just hangs (at least unusable). This is something I don't understand. I have 16 GB RAM, why can't I load a 100 MB file in an editor?

Is it because of Vim? I thought all the memory management is handled by the OS.

Best Answer

Vim sometimes has trouble with files that have unusually long lines. It's a text editor, so it's designed for text files, with line lengths that are usually at most a few hundred characters wide.

A database file may not contain many newline characters, so it could conceivably be one single 100 Mb long line. Vim will not be happy with that, and although it will probably work, it might take quite a long time to load the file.

I have certainly opened text files much larger than 100 Mb with Vim. The file doesn't even need to fit in memory all at once (since Vim can swap changes to disk as needed).