Alt-Up/Down Arrow Line Movement



  • I wanted to propose a minor feature. I didn’t see a feature request section other than plug-ins which this doesn’t sound like a plug-in as much as a core feature. Visual Studio allows moving a line of text up or down by pressing ALT-UP ARROW or ALT-DOWN ARROW.

    Thanks for the consideration.



  • welcome to the notepad++ community, @Edward-Ries

    to move a line up or down using the cursor keys, please press ctrl+shift+up or ctrl+shift+down in notepad++.
    (this shortcut triggers edit > line operations > move up/down current line)

    you can customise and change this default keyboard shortcut to your desire at the notepad++ menu settings > shortcut mapper.

    best regards.



  • Hello, @edward-ries and All,

    I just want to add an important point to @meta-chuh post : the Ctrl + Shift + Up and Ctrl + Shift + Down actions also act on selections, too, whatever its size !

    Note that, in case of multi-selections ( using the Ctrl key ) :

    • All the additional selections are appended to the main selection, in their order of creation, first

    • Secondly, all the resulting block of lines is moved up or down, accordingly :

    Cheers,

    guy038



  • That’s awesome, I was able to easily remap to alt-up and alt-down. I’m very pleased.



  • @guy038

    Multi-selections with this yield results that are not expected. Can you explain why you seem to think the behavior you get when doing this is desirable?



  • Hello @alan-kilborn and All,

    To be honest, Alan, I’ve never used yet, these shortcuts with multi-selections ! but, while preparing my reply to @edward-ries, I asked myself : what about multi-selections, while using the Ctrl + Shift + Down and Ctrl + Shift + Up shortcuts ? And I just described the way N++ gathers all the selections before moving, which seemed logic to me ;-)) Of course, I understand that, most of time, this result is not desirable at all !

    However, note that I very frequently use these two shortcuts when acting on the main selection of a block of consecutive lines !!

    Best Regards,

    guy038



  • @guy038 said:

    I very frequently use these two shortcuts when acting on the main selection of a block of consecutive lines !!

    Oh, yes; absolutely for the single-selection case. It is very nice that you don’t even have to have complete lines at the start or end of block selected first; the void Editor::MoveSelectedLines() function takes care of moving your selection to the proper place for you, before moving the lines up/down.

    But truly, the multiselection case boggles the mind. Of course, this is different from a lot of editing actions, where multiselections are ignored and only the “main” selection (the most recent one made) is manipulated.