Tim Chase wrote: >> 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 > There are several things that vim is/may be doing that perl processing is not:
* syntax highlighting * undo * checking for autocmd events, and executing associated code when they're triggered * swapfile/backup work * folding The LargeFile.vim script that Tim mentions turns several of these time consumers off for "large" files, the definition for which you may customize by setting the "g:LargeFile" variable. I don't think LargeFile is switching off paren matching -- that's probably a good idea (thanks, Tim!) for me to add (a blindspot of mine as I have paren matching turned off by default, anyway). Regards, Chip Campbell --~--~---------~--~----~------------~-------~--~----~ You received this message from the "vim_use" maillist. For more information, visit http://www.vim.org/maillist.php -~----------~----~----~----~------~----~------~--~---
