Tuesday, September 1, 2009

Re: improving the :join command

Hi Gene!

On Di, 01 Sep 2009, Gene Kwiecinski wrote:

> No disrespect intended, but *why* in B'Harni's Dark Name would you
> want to join >10000 lines into 1?!?

There might be usecases. Data is growing rapidly today, and I myself
had to manage automatically generated text-files of several hundred MB
of size. Plus there have occasionally been questions on this list
regarding joining lines.

Well just one simple test:

#v+
~$ for i in 1 2 4 8 16 32 64 128; do
seq 1 $(($i*1000)) > tempfile
echo "joining $i kilo lines"
time vim -u NONE -N -c ':%join|:q!' tempfile;
done
#v-

and compare the timings yourself. Doesn't this look like a bug to you?

> Any 'vi' variant is a *line*-based editor, which presumed a modest
> line-size for each. Juggling lines back and forth is easy, but heaving
> huge MB-sized chunks o' text is just obscene. Add to that syntax-based
> highlighting, multiple colors, etc., and all the processing required for
> just *1* line adds exponentially to the amount of work involved, let
> alone cursor motions, etc.

Well Vim is an editor. Shouldn't it be able to join properly millions
of lines, even if that sounds strange? The power of vim comes from
the fact, that you can do many different manipulations very
efficiently and does not limit you.

Plus :h limits does not talk about joining only a couple of lines ;)

> Dunno, but to me, that seems like using a text editor to edit a .jpg or
> .gif or something, ie, not the right tool for the job, even if, through
> herculean contortions and torturing the editor's functionality, it *can*
> be done.

Exactly. It can. And it might be done by someone.

> I'd, if anything, edit the file as needed, save it, then use 'sed',
> 'tr', etc., to post-process it accordingly. No overhead for syntax,
> colorschemes, etc. Ie, use the right tool for the job.

Yeah, but sed, tr, awk, perl, $language is not always available. And
Vim should be able to do it right.

What was the reason again to add :vimgrep to vim when grep is
available?

regards,
Christian

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

No comments: