Community

    • Login
    • Search
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    improve SCI_LINEDELETE shortcut

    Help wanted · · · – – – · · ·
    2
    8
    246
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Earth Invader
      Earth Invader last edited by

      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

      Alan Kilborn 2 Replies Last reply Reply Quote 0
      • Alan Kilborn
        Alan Kilborn @Earth Invader last edited by Alan Kilborn

        @earth-invader

        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.

        Earth Invader 1 Reply Last reply Reply Quote 2
        • Earth Invader
          Earth Invader @Alan Kilborn last edited by Earth Invader

          @alan-kilborn ok thanks

          Alan Kilborn 1 Reply Last reply Reply Quote 0
          • Alan Kilborn
            Alan Kilborn @Earth Invader last edited by Alan Kilborn

            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()
            
            1 Reply Last reply Reply Quote 2
            • Alan Kilborn
              Alan Kilborn @Earth Invader last edited by

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

              Earth Invader 1 Reply Last reply Reply Quote 2
              • Earth Invader
                Earth Invader @Alan Kilborn last edited by

                @alan-kilborn

                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.

                Alan Kilborn 1 Reply Last reply Reply Quote 0
                • Alan Kilborn
                  Alan Kilborn @Earth Invader last edited by

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

                  Earth Invader 1 Reply Last reply Reply Quote 1
                  • Earth Invader
                    Earth Invader @Alan Kilborn last edited by

                    @alan-kilborn
                    Thanks. it works.

                    1 Reply Last reply Reply Quote 1
                    • First post
                      Last post
                    Copyright © 2014 NodeBB Forums | Contributors