Add "Remove Duplicate Lines" feature
Remove duplicate consecutive lines from whole document.
This commit is contained in:
parent
e691370e4f
commit
51f10bdba5
@ -1406,6 +1406,23 @@ void Notepad_plus::removeEmptyLine(bool isBlankContained)
|
||||
_findReplaceDlg.processAll(ProcessReplaceAll, &env, true);
|
||||
}
|
||||
|
||||
void Notepad_plus::removeDuplicateLines()
|
||||
{
|
||||
// whichPart : line head or line tail
|
||||
FindOption env;
|
||||
|
||||
env._str2Search = TEXT("^(.*\\r?\\n)(\\1)+");
|
||||
env._str4Replace = TEXT("\\1");
|
||||
env._searchType = FindRegex;
|
||||
_findReplaceDlg.processAll(ProcessReplaceAll, &env, true);
|
||||
|
||||
// remove the last line if it's a duplicate line.
|
||||
env._str2Search = TEXT("^(.+)\\r?\\n(\\1)");
|
||||
env._str4Replace = TEXT("\\1");
|
||||
env._searchType = FindRegex;
|
||||
_findReplaceDlg.processAll(ProcessReplaceAll, &env, true);
|
||||
}
|
||||
|
||||
void Notepad_plus::getMatchedFileNames(const TCHAR *dir, const vector<generic_string> & patterns, vector<generic_string> & fileNames, bool isRecursive, bool isInHiddenDir)
|
||||
{
|
||||
generic_string dirFilter(dir);
|
||||
|
@ -589,6 +589,7 @@ private:
|
||||
void wsTabConvert(spaceTab whichWay);
|
||||
void doTrim(trimOp whichPart);
|
||||
void removeEmptyLine(bool isBlankContained);
|
||||
void removeDuplicateLines();
|
||||
void launchAnsiCharPanel();
|
||||
void launchClipboardHistoryPanel();
|
||||
void launchFileSwitcherPanel();
|
||||
|
@ -298,6 +298,7 @@ BEGIN
|
||||
POPUP "Line Operations"
|
||||
BEGIN
|
||||
MENUITEM "Duplicate Current Line", IDM_EDIT_DUP_LINE
|
||||
MENUITEM "Remove Duplicate Lines", IDM_EDIT_REMOVE_DUP_LINES
|
||||
MENUITEM "Split Lines", IDM_EDIT_SPLIT_LINES
|
||||
MENUITEM "Join Lines", IDM_EDIT_JOIN_LINES
|
||||
MENUITEM "Move Up Current Line", IDM_EDIT_LINE_UP
|
||||
|
@ -1384,6 +1384,12 @@ void Notepad_plus::command(int id)
|
||||
_pEditView->execute(SCI_LINEDUPLICATE);
|
||||
break;
|
||||
|
||||
case IDM_EDIT_REMOVE_DUP_LINES:
|
||||
_pEditView->execute(SCI_BEGINUNDOACTION);
|
||||
removeDuplicateLines();
|
||||
_pEditView->execute(SCI_ENDUNDOACTION);
|
||||
break;
|
||||
|
||||
case IDM_EDIT_SPLIT_LINES:
|
||||
_pEditView->execute(SCI_TARGETFROMSELECTION);
|
||||
if (_pEditView->execute(SCI_GETEDGEMODE) == EDGE_NONE)
|
||||
|
@ -104,6 +104,7 @@
|
||||
#define IDM_EDIT_INS_TAB (IDM_EDIT + 8)
|
||||
#define IDM_EDIT_RMV_TAB (IDM_EDIT + 9)
|
||||
#define IDM_EDIT_DUP_LINE (IDM_EDIT + 10)
|
||||
#define IDM_EDIT_REMOVE_DUP_LINES (IDM_EDIT + 77)
|
||||
#define IDM_EDIT_TRANSPOSE_LINE (IDM_EDIT + 11)
|
||||
#define IDM_EDIT_SPLIT_LINES (IDM_EDIT + 12)
|
||||
#define IDM_EDIT_JOIN_LINES (IDM_EDIT + 13)
|
||||
|
Loading…
Reference in New Issue
Block a user