Thanks, Andy; the black hole register is a new idea to me. Unfortunately,
":.,$d _" to the black hole register appears to take the same amount of
time as ":.,$d" itself. "set undolevels=-1" speeds it up, but "set
undolevels=0" does not; this suggests to me that the problem isn't related
to how many undo buffers are around, just that the undo facility is
available at all.
Honestly, the 3 minutes it takes has to involve a significant amount of
waste, such as timing out for some system resource; reading the 2 million
line file into memory doesn't take that long in the first place, and the
delete is the first change I make to the file, so there isn't a stack of
buffers filled with undo information to start with.
Max
On Tue, 22 May 2007, Andy Wokula wrote:
A.J.Mechelynck schrieb:
Robert M Robinson wrote:
First, thanks very much for creating VIM! I have been using it on Linux
systems for years, and now use it via cygwin at home as well. I vastly
prefer VIM to EMACS, especially at home. I learned vi on a VAX/VMS
system long ago (a friend of mine had ported it), when our computer
science department was loading so many people on the VAXen that EDT was
rendered unusably slow. I still like VIM largely because I can do so
much with so little effort in so little time.
That brings me to my question. I have noticed that when editing large
files (millions of lines), deleting a large number of lines (say,
hundreds of thousands to millions) takes an unbelieveably long time in
VIM--at least on my systems. This struck me as so odd, I looked you up
(for the first time in all my years of use) so I could ask why!
Seriously, going to line 1 million of a 2 million line file and typing
the command ":.,$d" takes _minutes_ on my system (Red Hat Linux on a
2GHz Athlon processor (i686), 512kb cache, 3 Gb memory), far longer than
searching the entire 2 million line file for a single word
(":g/MyQueryName/p"). Doing it this way fits way better into my usual
workflow than using "head -n 1000000", because of course I'm using a
regular expression search to determine that I
want to truncate my file at line 1000000 in the first place.
I looked in the archive, and couldn't see that this issue had been
raised before. Is there any chance it can get added to the list of
performance enhancement requests?
Thanks,
Max Robinson, PhD
I think this is just "part of how Vim behaves".
When you edit a file, Vim holds the whole file in memory (IIUC). When you
delete a million lines, Vim frees (i.e., releases to the OS) the memory
those lines were using. That takes some time.
Best regards,
Tony.
What about the numbered registers?
:h "1
After freeing the lines, they are copied to "1 .
And the content of "1 is shifted to "2 (before, of course)
And so on, until register "9.
To avoid the copies, the blackhole register can be used:
:.,$d _
If there are copies, registeres can be cleared by hand:
:let @1 = ""
:let @2 = ""
...
:let @9 = ""
This also takes time, but frees the memory.
--
Regards,
Andy