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 the end of the line,
> sort the file,
> delete duplicate lines ignoring the linenumber,
> move the line number to the start of the line,
> sort,
> remove the line number.
>
> Is there a more simple way?
>

As a refinement of your original method, I expected this to work:

1. Insert line number at BEGINNING of the line
2. ":sort /^\d\+ / u" to sort, removing duplicate lines, ignoring the
line number at the beginning of the line
3. ":sort n" to sort on line number
4. remove line number

But, it seems the 'u' flag does not ignore the /pattern/ as the sort
itself does. I expected u and /pattern/ to work together since u and i
work together just fine. Does anyone know if this is intentional?

Anyway, even if you cannot automatically remove duplicate lines with
the u flag, it saves the step of moving the line number around.

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