Paste "forward" without moving the cursor position?

  • Iago-lito

    Iago-lito - 2014-04-03


    I'd like to find a way to achieve this particular trick in Notepad++, cause it'd be helpful for my macros:

    Is there any way to paste text "forward", that is: "the pasted text goes after your cursor location" or "your cursor moves back to its orginal position after pasting" or "any character you'd type just after pasting would be printed not after but right before the pasted text" ?

    If there was, that'd be great, but I just can't find it anywhere.

    This is all, thanks !


  • cchris

    cchris - 2014-04-05

    The following is a little hacky, but works:
    1/ If the SCI_SWAPMAINANCHORCARET isn't bound to a key combination, please bind it from Shortcut Maper. Assume you chose Ctrl-Alt-Numpad4 for this.
    2/Now the following maro will do what you want:
    Ctrl-Alt-Numpad4 -- sets caret at start of pasted and still selected text)
    Right -- kill selectuib
    Left -- back to deired location


  • Iago-lito

    Iago-lito - 2014-04-11

    Thanks CChris. As I was expecting something like this, I feel that there's nothing hacky with it. ;)

    This would work fine if the pasted text was actually selected right after pasting. But it's not, so swapping the anchor doesn't change anything.

    Or maybe the text you paste is selected when you Ctrl-V whereas mine is not. Is that the case?

    If yes, maybe I should open a new thread « How to get pasted text selected? ».


  • Loreia2

    Loreia2 - 2014-04-12


    Python tends to make most problems trivial. Install Python plugin (Plugins / Plugin manager), create new script and paste this into it:

    pos = editor.getCurrentPos()

    I guess code this simple doesn't require further explanation :-)
    Now, just go to Plugin configuration and add this script to menu or toolbar, and assign a keyboard shortcut to it, say CTRL+SHIFT+V


  • Iago-lito

    Iago-lito - 2014-04-12

    Awesome. This works perfect and opens a brand new sexy world indeed! I can't help translating all my previous hacky macros to Python now and improving them. My new n++ era has begun :P

    Thank you Loreia!


  • Loreia2

    Loreia2 - 2014-04-13

    I can't help translating all my previous hacky macros to Python now and improving them. My new n++ era has begun :P

    That's the spirit !!
    Documentation is here:

    Happy coding.
    If you create something, you feel, is worthy of sharing, just paste it here, so other users could benefit too.


  • Iago-lito

    Iago-lito - 2014-04-13

    Sure! `Nothing amazing yet of course, but if I get anything cool one day, I'll be right back.


  • REVerdi

    REVerdi - 2014-10-14

    The code by Loreia2 works, but there is some problem when changing line, because the cursor moves to the final column of the pasted text. The code below solves this problem:

    col = editor.getColumn( editor.getCurrentPos() )
    if editor.canPaste():
       for x in range(0, col):
    Last edit: REVerdi 2014-10-14

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks