If the file is large, but the number of resulting unduplicated lines is manageably small (say a couple megs), you can do it in O(N) rather than O(N^2) or O(N*M) where N is the number of lines and M the number of duplicates. Just store each line in a dict as you process them and then delete them if you encounter them again:

:let a={}|g/^/let k=getline('.')|if has_key(a,k)|d|else|let a[k]=1|endif
:unlet a

This has the advantage that you can do transforms on the key if you want, changing the "let k=getline('.')" to strip off leading/trailing whitespace, normalize the case, etc.

Hope this gives you another option,

-tim


--
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

Reply via email to