Wednesday, July 6, 2011

Re: Deleting duplicate lines _without_ sorting

2011/7/6 Tony Mechelynck <antoine.mechelynck@gmail.com>:
> well, maybe, but probably not as fast since its processing time would be on
> the order of the square of the number of lines: simply write a function with
> a double loop, which would examine all lines 1→$ in turn in the outer loop
> then compare it with all following lines $→(i+1) in turn in an inner loop,
> and delete the later line if equal. Scanning forward in the outer loop and
> backward in the inner loop ensures that you don't get line numbers changed
> before you have finished using them. But the end-of-loop test for the outer
> loop must recompute line('$') at every interation.
>

You are right but if it is only one file and this macro will never be
used as a script to do this automatically etc. it should be fast
enough ;)

Best Regards,
Karol

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments:

Post a Comment