Re: Deleting duplicate lines _without_ sorting

2011-07-08 Thread rameo
Have you checked the one I mentioned above? The one above is working in menu-vim (the pipe symbol has to be escaped in menu.vim) To let it work in the commandline the escape before the pipe symbol has to be removed: g/^/kl |if search('^'.escape(getline('.'),'\.*[]^$/').'$','bW') |'ld The only

Re: Deleting duplicate lines _without_ sorting

2011-07-07 Thread rameo
Hi Stefan, I found this one a few weeks ago. It does the job without sorting. :g/^/kl \|if search('^'.escape(getline('.'),'\.*[]^$/').'$','bW') \|'ld Regards, Rameo -- You received this message from the vim_use maillist. Do not top-post! Type your reply below the text you are replying to. For

Re: Deleting duplicate lines _without_ sorting

2011-07-07 Thread Tim Chase
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

Re: Deleting duplicate lines _without_ sorting

2011-07-07 Thread Ben Fritz
On Jul 6, 4:02 am, Stefan Klein st.fankl...@googlemail.com wrote: Hi vim users, i got a longer SQL script with duplicate inserts :/ I'd like to remove those without sorting the whole file. It's possible to match the lines by a pattern. One solution might be to insert the line number at

Deleting duplicate lines _without_ sorting

2011-07-06 Thread Stefan Klein
Hi vim users, i got a longer SQL script with duplicate inserts :/ I'd like to remove those without sorting the whole file. It's possible to match the lines by a pattern. One solution might be to insert the line number at the end of the line, sort the file, delete duplicate lines ignoring the

Re: Deleting duplicate lines _without_ sorting

2011-07-06 Thread Karol Samborski
Hi Stefan, I would do simple macro like this one (before starting recording macro place cursor on the first column of the first line you want to check): qa -- start recording macro 'a' y$ -- copy whole line j -- place the cursor one line down :,$g/ -- we want to delete every duplicate of copied

Re: Deleting duplicate lines _without_ sorting

2011-07-06 Thread Tony Mechelynck
On 06/07/11 11:02, Stefan Klein wrote: Hi vim users, i got a longer SQL script with duplicate inserts :/ I'd like to remove those without sorting the whole file. It's possible to match the lines by a pattern. One solution might be to insert the line number at the end of the line, sort the

Re: Deleting duplicate lines _without_ sorting

2011-07-06 Thread Karol Samborski
2011/7/6 Tony Mechelynck antoine.mechely...@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

Re: Deleting duplicate lines _without_ sorting

2011-07-06 Thread Karol Samborski
2011/7/6 Karol Samborski edv.ka...@gmail.com: 2011/7/6 Tony Mechelynck antoine.mechely...@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

Re: Deleting duplicate lines _without_ sorting

2011-07-06 Thread Stefan Klein
Hi Karol, 2011/7/6 Karol Samborski edv.ka...@gmail.com Hi Stefan, I would do simple macro like this one (before starting recording macro place cursor on the first column of the first line you want to check): qa -- start recording macro 'a' y$ -- copy whole line j -- place the cursor one