Automatically copy selected text?



  • Some platforms (Unix/X11) and tools (UltraEdit) can automatically copy selected text to the clipboard (without having to ctrl-C or right-click). Is there some way to configure Notepad++ to do this?

    Thanks!



  • @Georg-Trimborn ,

    That is not a feature that’s been implemented in Notepad++, as far as I know. If someone else disagrees, they can chime in.

    Given the right notification to hook into, it might be doable in PythonScript or thru a plugin, but I don’t know of an already-existing plugin that handles that, nor do I know off the top of my head which is the right Scintilla notification to hook into.



  • @Georg-Trimborn said in Automatically copy selected text?:

    Is there some way to configure Notepad++ to do this?

    This plugin supposedly does that:

    https://github.com/KubaDee/SelectToClipboard/

    Cheers.



  • @PeterJones said in Automatically copy selected text?:

    …Pythonscript…which is the right Scintilla notification to hook into.

    Wouldn’t one just hook into the editor window’s WM_LBUTTONUP message, and then if editor.getSelectionEmpty() is False, do an editor.copy() ?

    If I had such a feature, I’d like something like an Esc keypress in between WM_LBUTTONDOWN and WM_LBUTTONUP to cancel the automatic copy, for those “oops” moments.



  • @Alan-Kilborn said in Automatically copy selected text?:

    Wouldn’t one just hook into the editor window’s WM_LBUTTONUP message, and then if editor.getSelectionEmpty() is False, do an editor.copy() ?

    That would probably do what was described/requested, yes.

    for those “oops” moments.

    “I had a huge amount of text in the clipboard, then I selected one word in Notepad++ because I was going to paste the clipboard to replace that word, and now my clipboard just contains that one word!”

    I think in the X11 (linux gui) environment, there are actually two copy-buffers: one for manual Ctrl+C/Ctrl+V and one for the selection-buffer, otherwise the sequence below wouldn’t work

    -----

    manual copy : __
    
    selection
    
    final paste: 
    
    ------
    
    1. copy "manual copy" using Ctrl+C
    2. highlight "selection"
    3. paste using Ctrl+V 
        => pastes "manual copy", not "selection", 
        so highlight-selection obviously didn't 
    4. undo
    5. select "selection"
    6. middle click between the underscores
        => it pastes "selection"
    7. go to after "final paste:" and Ctrl+V paste
        => it pastes "manual copy", so the 
        pasting of the highlighted "selection"
        didn't overwrite the clipboard
    

    -----

    Personally, if I had such a feature in Notepad++, I would want it to be “look at the contents of the active selection, and insert that text here”, not “put the contents of the active selection in the clipboard then paste here”. Of course, that would only work inside of Notepad++, and wouldn’t have the cross-application capabilities that X11 includes for the selection-buffer pasting.



  • @PeterJones

    Two buffers is a good idea, although as you state it requires two different ways of invoking a paste. The one for the auto-copied text might be thought of as a Paste-special.

    Personally, if I had such a feature in Notepad++, I would want it to be “look at the contents of the active selection, and insert that text here”, not “put the contents of the active selection in the clipboard then paste here”

    For some reason that made my head hurt, but I think I understand its meaning. :)



  • @Alan-Kilborn said in Automatically copy selected text?:

    Two buffers is a good idea, although as you state it requires two different ways of invoking a paste. The one for the auto-copied text might be thought of as a Paste-special.

    Not to be confused with this Paste-special. :-)

    Oddly, my Chrome browser in Windows (and/or this forum) actually already has a second buffer or equivalent: when I highlight the above line and click Reply, it auto-populates with just that portion of your text. But my clipboard is still there, because I was able to paste the URL. :-)



  • @PeterJones said in Automatically copy selected text?:

    Not to be confused with this Paste-special.

    As I was composing earlier I almost said YAPS (yet-another-paste-special). Indeed, I already have a subfolder under Scripts in my Pythonscript menu in N++ called PasteSpecial (because there are a lot of them). What I really need is a PasteSpecialManager.

    my Chrome browser in Windows (and/or this forum) actually already has a second buffer or equivalent: when I highlight the above line and click Reply, it auto-populates with just that portion of your text

    Yes, very handy, but there’s no reason that functionality even needs to mess with the clipboard to do what it does. Like when a Pythonscript does editor.getSelText() in order to manipulate some text (within N++), the clipboard is not involved/affected.



  • @Alan-Kilborn said in Automatically copy selected text?:

    there’s no reason that functionality even needs to mess with the clipboard to do what it does

    Indeed. That was the point I was trying to make that made your head hurt. :-)


Log in to reply