Bug 319262 - Script to remove duplicate lines
Summary: Script to remove duplicate lines
Status: RESOLVED WORKSFORME
Alias: None
Product: kate
Classification: Applications
Component: scripting (other bugs)
Version First Reported In: 3.10.2
Platform: openSUSE Linux
: NOR wishlist
Target Milestone: ---
Assignee: KWrite Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-05-03 09:18 UTC by Todd
Modified: 2017-11-14 18:01 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Todd 2013-05-03 09:18:57 UTC
Kate scripts currently allow you to sort selected lines and duplicate selected lines.  However, as far as I can tell there is no way in kate, either with existing scripts or with regular expressions, to remove duplicate lines (i.e. multiple identical lines).  It would be nice if a script was added that would remove duplicate lines in a selection.

I think that many the same use-cases that would see someone want to sort lines would also see that person want to remove redundant lines once they are sorted.  

At least for me I wouldn't care whether this works only on sequential duplicates (i.e. lines n and n+1 are the same) or remove duplicates throughout the document (i.e. lines n and m are the same).  The sequential case would be faster, but would generally only work on sorted lists.  I suppose both could be added.

Reproducible: Always
Comment 1 Todd 2013-05-03 09:35:41 UTC
Looking at the scripting code, it appears this functionality has already been implemented.  However, it is not made available to the user in the menu.  There appear to be a bunch of functions in utils.js that could be placed in the menu but aren't, and this is one of them.
Comment 2 Dominik Haumann 2013-05-03 14:20:35 UTC
select text, F7 (switch to the command line) and type 'uniq'

That's exactly what you are looking for. I'm not sure whether putting every possible action we have into the gui is a good idea. I'll close this particular issue as works-for-me, since it's there :)