Well if we are opening it up to scripts, then I’ll offer up the following Pythonscript; I call it DeleteLinesWithClipboardText.py:
def DLWCT__main():
if not editor.getSelectionEmpty(): return # keep it simple; maybe prompt user to cancel selection and re-run...
if not editor.canPaste(): return # keep it simple; maybe prompt user that no text is in clipboard...
orig_document_len = editor.getTextLength()
editor.beginUndoAction()
editor.paste()
pasted_text_len = editor.getTextLength() - orig_document_len
curr_pos = editor.getCurrentPos()
clipboard_text = editor.getTextRange(curr_pos - pasted_text_len, curr_pos)
editor.deleteRange(curr_pos - pasted_text_len, pasted_text_len)
if '\r' in clipboard_text or '\n' in clipboard_text:
# keep it simple; don't allow multiline search text
editor.endUndoAction()
return
del_line_list = []
find_start_pos = 0
while True:
f = editor.findText(FINDOPTION.MATCHCASE, find_start_pos, editor.getTextLength(), clipboard_text)
if f == None: break
(found_start_pos, found_end_pos) = f
line_nbr = editor.lineFromPosition(found_start_pos)
if len(del_line_list) > 0:
if del_line_list[0] != line_nbr: del_line_list.insert(0, line_nbr)
else:
del_line_list.append(line_nbr)
find_start_pos = found_end_pos
for line in del_line_list: editor.deleteLine(line)
editor.endUndoAction()
DLWCT__main()
The only tricky part is in getting the clipboard data. I paste the clipboard contents into the document, read what was just pasted, and then delete those contents. After that it is a simple matter to locate the desired text and delete the lines it occurs on.