As title. I just faced a situation that I have to browse some large file (for human, not machine perspective) with around 10,000~50,000 lines. Is it possible to only load those line that can be seen from the current window? E.g. Line 9542~9596, and add/release lines when scroll. I expect that this will increase the performance largely.
No. From the
readfile function in fileio.c:
/* * We allocate as much space for the file as we can get, plus * space for the old line plus room for one terminating NUL. * The amount is limited by the fact that read() only can read * up to max_unsigned characters (and other things). */
strace -o logfile vim -u NONE largefile confirms that Vim will indeed entirely load the entire file by issuing as many
read calls as necessary (you will find them right after the first
...and add/release lines when scroll. I expect that this will increase the performance largely.
Not really. The only significant performance gain would be in the start up time, simply because initially only a window worth of lines would be read from disk into memory.
Assuming the file fits in memory (and yours is only a few MiB in size), once it is loaded, there is no performance penalty in keeping it there.
Sluggishness on large files may be caused by plugins, as you found out to be your case by running
vim --noplugin largefile