> I have a text file that is very large. It has only one line which is
> of the form like below.
> itemA itemB itemC ......
> 
> Basically itemA, itemB etc are character strings of some arbitrary
> length and they are separated by a space.
> 
> I wanted to modify the file so that each line will have only one item.
> The next item after a certain item will be placed in the next line. So
> this is fairly easy with a ":s/ /\r/g" command. The problem is when I
> have about a million of such items, this takes very long. It was going
> on for about two hours and then I killed the vim session. Then I tried
> to achieve the same result writing a small perl script (using split),
> and I was surprised that it took less than 10 seconds to finish.

I'd use the standard "tr" utility available on most *nix boxes:

   tr ' ' '\n' <in.txt >out.txt

which should be about as fast as it gets (eliminating Vim 
altogether).

There are a number of things in Vim that could be causing 
slowness:  syntax highlighting, paren matching, undo levels, etc.

Dr. Chip maintains a "largefile" script that may help:

http://www.vim.org/scripts/script.php?script_id=1506

-tim




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

Reply via email to