Copy Line Without Line Feed



  • When highlighting/selecting a complete line by double clicking or clicking at the front of the line, it also selects the line feed at the end. Is there a setting or a way to allow selecting a complete line without the line feed?



  • You could record a macro that does HOME -> HOME -> SHIFT-END and assign it a hot key. The first HOME brings it to the first non-whitespace character in the line, the second HOME will bring it to zero column.



  • Tried that and it works, giving me a workaround. I was hoping there was a setting that changed the default of copying the ‘complete’ line with CR/LF to just copying the text without. It becomes about workflow and needing to add extra keystrokes to get the job done instead of just clicking at the front of the line and pressing Ctrl-C quickly. Maybe a “New Feature” request?? LOL



  • @Adam-Brannon

    Many people will argue that it is not a (complete) “line” without a line-ending on it (and I would tend to agree with that definition), thus when you triple (not double!) click a line, it should select contents plus line-ending.

    The workflow can actually be improved by the macro approach…you could add the “copy” to it for reduced action count if you do this often. I think the complaint with the workflow you made might be because you have to do something different than what you are used to doing.

    I think the “HOME -> HOME -> SHIFT-END” approach has a slight flaw–depending upon where the caret is on the line when this is invoked, you might end up not getting the entire desired text selected (hint: try the sequence with the caret right on the first non-whitespace character of an indented line). This assumes that the Home key is mapped to its default setting (and of course same for Shift+End). Better would be a single press of Alt+Home (again, default kemapping) followed by the Shift+End.



  • Hi, @adam-brannon , @scott-sumner and All,

    Scoot, I did some tests, also considering the case of an indented line, which is wrapped in several physical lines, with the cursor on the first physical line OR on the following ones !


    And , to my mind, the best way, by macro, to select any complete line, without its End of Line chars, whatever the cursor location , with the default N++ shortcuts, should be any of the 5 shortcuts sequences, below :

    Alt + Home , Home, Home, Shift + End, Shift + End

    Home, Home, Alt + Home , Shift + End, Shift + End ( Thanks to Scott )

    If you also want to select its line-break, simply add the Shift + Right Arrow shortcut


    I tested this sequence with :

    • A single line non-indented

    • A single line, indented

    • A multi-lines non-indented

    • A multi-lines indented

    I tried with and w/o the menu option View > Word wrap and with each case of Line Wrap, in Settings > Preferences...> Editing ( Default, Aligned and Indent )

    Best Regards,

    guy038



  • @guy038

    Ha! Of course you are right. I now notice in my Macro menu that I have something called “Select current line without EOL”. Opening shortcuts.xml I see that it is defined as follows:

        <Macro name="Select current line without EOL" Ctrl="no" Alt="no" Shift="no" Key="0">
            <Action type="0" message="2453" wParam="0" lParam="0" sParam="" />
            <Action type="0" message="2453" wParam="0" lParam="0" sParam="" />
            <Action type="0" message="2345" wParam="0" lParam="0" sParam="" />
            <Action type="0" message="2315" wParam="0" lParam="0" sParam="" />
            <Action type="0" message="2315" wParam="0" lParam="0" sParam="" />
        </Macro>
    

    I’m not going to look it up, but I will wager that these are exactly the 5 command steps that you outlined directly above. What this all means is…I’m sure we’ve discussed this before in the Community! And, of course, that turns out to be true… :-D

    Time for a FAQ Desk about this?


Log in to reply