Something amazingly useful I fear is not a thing regarding deleting text



  • I am an admin. It look at mountains of log files. Often I need to just pass or keep sections of the logs.
    I would like to know if there is a way to ‘crop’ my text files.
    By this, I mean I want to highlight a certain portion of text and then delete everything that is NOT highlighted with a right click or shortcut key.
    I AM AN ADMIN. I repeat this to make clear I am obviously aware how to copy paste. I do not wish to create a new document. I wish to flush unnecessary miles of my current document.
    Is this possible?
    Thank you for your time.



  • @Craig-Beringhaus

    Most useful for you would be an “Invert Selection” command, that would take your current selection and select everything else. Then a tap of the Delete key and you are done.

    Alas, there is no such command in Notepad++.

    Plus, it is complicated, because it would require “multi-select” to be enabled, because in most cases, you would need such a selection inversion command to select a block before your selection and a block after your selection.


    But all is not lost…

    A simple thing that seems to work is to record a macro for the following actions, in order:

    • Copy (Ctrl+c)
    • Select All (Ctrl+a)
    • Paste (Ctrl+v)

    Then you give it a name and assign a keycombo to it.
    When you want to actually use it, you select the text you want to keep, then run the macro via the assigned keycombo.

    Of course, the slight downside may be that it destroys your clipboard contents, but perhaps this is a small deficiency.



  • @Alan-Kilborn
    Thank you!
    Sad that it’s not pre-existing, but you think outside the box. I like it!



  • @Craig-Beringhaus
    and there is this copy styled text feature in the search menu,
    which could be used within the macro if more than one block of text is highlighted



  • @Ekopalypse said in Something amazingly useful I fear is not a thing regarding deleting text:

    and there is this copy styled text feature in the search menu,
    which could be used within the macro if more than one block of text is highlighted

    Actually, if Multi-Editing is enabled, the original macro handles “more than one block” just fine, no need to dabble in “styles” or “Copy Styled Text”.

    e43a4b11-11a5-4605-a058-9ec00f471712-image.png



  • Yes, but copy selected text does not need to have multiple selections active at the time of doing the copy.


Log in to reply