improve SCI_LINEDELETE shortcut
-
When I use Visual Studio, pressing 'delete line" shortcut will delete any lines with selection.
Can you make it so that notepad++ SCI_LINEDELETE key mapping to also delete multiple lines when multiple lines are selected. It on delete the 1st line of the selection in the current version.Thanks
-
This is probably not a bad idea, but Notepad++ doesn’t control this functionality; Scintilla does. As Scintilla is a separate project, you’d have to make a feature request to that project for a change. You can do that HERE.
-
@alan-kilborn ok thanks
-
Here’s a PythonScript called
LineDelete.py
that implements the functionality:# -*- coding: utf-8 -*- #------------------------------------------------------------------------------- class LD(object): def __init__(self): if editor.getSelections() > 1 and not editor.selectionIsRectangle(): return # unsupported for now editor.beginUndoAction() if editor.getCurrentPos() != editor.getAnchor(): (line_start, line_end) = editor.getUserLineSelection() if line_start != line_end: start_pos = editor.positionFromLine(line_start) end_pos = editor.getLineEndPosition(line_end) editor.deleteRange(start_pos, end_pos - start_pos) editor.lineDelete() editor.endUndoAction() #------------------------------------------------------------------------------- if __name__ == '__main__': LD()
-
@earth-invader said in improve SCI_LINEDELETE shortcut:
It only deletes the 1st line of the selection in the current version.
Actually, it deletes the line of the caret, which isn’t always the 1st line.
If you start making your selection from the top of your window and then lengthen it towards the bottom, when you stop your caret position will be on the bottom-most line, so that one will be the one deleted with SCI_LINEDELETE.
If you do it the other way, from lower on the window toward the upper part of the window, then yes, you are correct, the 1st line of the selection will be the one deleted with SCI_LINEDELETE.
-
How do I use your script? I installed PythonScript plugin and placed the script in the script folder but after restart, it still only delete one line.
-
@earth-invader said in improve SCI_LINEDELETE shortcut:
How do I use your script? I installed PythonScript plugin and placed the script in the script folder but after restart, it still only delete one line.
See HERE.
-
@alan-kilborn
Thanks. it works.