Community
    • Login

    How to prevent newline character when marking a line

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    9 Posts 6 Posters 7.9k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Michael FitzenM
      Michael Fitzen
      last edited by

      Hi,

      i already posted it at the google+
      community:https://plus.google.com/+MichaelFitzen/posts/XTRkh1bTL76

      How can i prevent the editor to place a newline character after marking
      a line via line numbers?

      For example: I have a txt file with 3 lines. If i mark line 2 by
      clicking the line number the cursor jumps into line 3. When i press
      ctrl+c it will copy the newline character in line 3. When i paste the
      copied line 2 into a plain file this files has 2 lines. The one with the
      content of line 2 and a blank one (line 3). I don´t want this to happen.
      I only want to copy the content of line 2!

      A workaround like press SHIFT+LEFT ARROW or something like this is not a solution for me! Any other editor can handle this too…

      Regards

      Michael

      1 Reply Last reply Reply Quote 0
      • guy038G
        guy038
        last edited by guy038

        Hello Michael,

        I think that you can achieve your goal with a macro. Tested with N++ v6.7.9, it’s quite OK !

        So, just follow these few steps below :

        • Open a new tab

        • Select the menu option View - Word Wrap or click on the associate button on the Toolbar

        • Type some spaces or tab characters, followed by any text, in order to create a long line which is wrapped, in, for instance, three lines

        • Type on the Enter key, to create the End of Line character(s)

        • Place the cursor, anywhere, in the LAST physical line of this long line

        • Select the menu option Macro - Start Recording or a click on the button, with a red circle, on the Toolbar

        • Hit, THREE times, the Origin key

        • Hit the SHIFT + End shortcut

        • Hit the CTRL + C shortcut

        • Hit the Left Arrow key

        • Select the menu option Macro - Stop Recording or a click on the button, with a black square, on the Toolbar

        • Select the menu option Macro - Save Current Recorded Macro…

        • Enter, for instance, Copy Visible Line as name of this new macro

        • Choose a shortcut to activate this macro ( take care NOT to use an existing N++ or plugin shortcut ! )

        • Click on the OK button, to valid your choices


        Now, to copy the entire text of a line, without its End of Line characters :

        • Locate the cursor anywhere in that line

        • Select the menu option Macro - Copy Visible Line or its associated shortcut

        • Place your cursor anywhere else in that new tab, or, even, in an other file, in a new line or inside some text

        • Finally, hit the classical CTRL + V shortcut, to paste the line contents, ONLY, at this new cursor location

        Et voilà !

        Note :

        We need to hit THREE times on the Origin key :

        1. To reach the beginning of the current physical line
        2. To reach the first non blank character of the entire line
        3. To reach the very beginning of the entire line

        Best Regards,

        guy038

        1 Reply Last reply Reply Quote 1
        • Michael FitzenM
          Michael Fitzen
          last edited by

          Hi & thx for your reply!

          This is maybe a workaround. I will try this. Thanks for your help.

          But why NP++ can`t handle this one like every other editor do? I tried to contact the author about this, but did not get any response. Is there any possibility to reporting bugs or feature request?

          1 Reply Last reply Reply Quote 0
          • Scott SumnerS
            Scott Sumner
            last edited by

            guy038,

            I found that doing the origin/home key THREE times causes any leading space not to be copied. Decreasing it to TWO times put the entire line (without the line-endings) into the paste buffer.

            1 Reply Last reply Reply Quote 0
            • guy038G
              guy038
              last edited by guy038

              Hi Michael and Scott,

              Indeed, Scott, if your cursor is located on the first physical line of a long line, you only need two hits on the Home key.

              However, if it’s located on the other physical lines of this long line, three hits on the Home key are needed.

              But, I found a work-around :

              • Two hits on the Home key, which will always locate the cursor on the first physical line, whatever the cursor’s position

              • One Alt + Home that always place the cursor at the very beginning of the current physical line

              So, the different macro’s actions are :

              • Hit, TWICE, the Home key

              • Hit the ALT + Home shortcut

              • Hit the SHIFT + End shortcut

              • Hit the CTRL + C shortcut

              • Hit the Left Arrow key

              Cheers,

              guy038

              1 Reply Last reply Reply Quote 1
              • glennfromiowaG
                glennfromiowa
                last edited by

                Hi Michael,

                I’m not sure what other editors you are using that select just the line without the newline when you click on the line number. Obviously, you have your preferences, but my main reason for replying is that I would consider it a bug if it did not select the newline when clicking on the line number. It is much easier to move lines around if I can just click on the line number and then click on the text to drag the whole line up or down. I would hope any feature requests to change this would include the option to select text either with or without the newline.

                Meta ChuhM 1 Reply Last reply Reply Quote 1
                • Meta ChuhM
                  Meta Chuh moderator @glennfromiowa
                  last edited by Meta Chuh

                  resurfaced because of this github issue report:
                  Clicking on the line number with the reverse mouse arrow selects a statement along with “newline”.
                  which was just commented with:

                  if it suffices you, to copy the line at the cursor to your clipboard with [shift]+[ctrl]+[c], completely trimmed of leading spaces, tabs and trailing line feeds, there’s a simple alternative, only using the built in functions:

                  • open %AppData%\Notepad++\shortcuts.xml in notepad++.
                  • paste the following code to your <Macros> section:
                          <Macro name="Copy Line" Ctrl="yes" Alt="no" Shift="yes" Key="67">
                              <Action type="0" message="2453" wParam="0" lParam="0" sParam="" />
                              <Action type="0" message="2453" wParam="0" lParam="0" sParam="" />
                              <Action type="0" message="2453" wParam="0" lParam="0" sParam="" />
                              <Action type="0" message="2452" wParam="0" lParam="0" sParam="" />
                              <Action type="0" message="2452" wParam="0" lParam="0" sParam="" />
                              <Action type="0" message="2452" wParam="0" lParam="0" sParam="" />
                              <Action type="0" message="2178" wParam="0" lParam="0" sParam="" />
                          </Macro>
                  
                  • save shortcuts.xml.
                  • restart notepad++.

                  now regardless of where you put your cursor in any line, [shift]+[ctrl]+[c] will trim-select the whole line and copy it to your clipboard.
                  paste it as usual using [ctrl]+[v] 😉

                  source: https://notepad-plus-plus.org/community/topic/84/how-to-prevent-newline-character-when-marking-a-line by our regex guru guy038.


                  btw: where is @glennfromiowa ?
                  why does he always leave for so long ?
                  ps: he’s the one, who originally reintroduced the welcome to … for new visitors 👍

                  Alan KilbornA 1 Reply Last reply Reply Quote 2
                  • Alan KilbornA
                    Alan Kilborn @Meta Chuh
                    last edited by

                    @Meta-Chuh

                    btw: where is @glennfromiowa ?

                    Yea! Why do we miss him when he is not here? Maybe it is his welcoming (but nerdy) face picture. :)

                    Meta ChuhM 1 Reply Last reply Reply Quote 2
                    • Meta ChuhM
                      Meta Chuh moderator @Alan Kilborn
                      last edited by Meta Chuh

                      @Alan-Kilborn

                      Yea! Why do we miss him when he is not here? Maybe it is his welcoming (but nerdy) face picture. :)

                      nerdy: so am i.
                      welcoming: not just that. recalling his posts from memory, he’s at least as elevated in knowledge as you or me, if not even far more than that.

                      1 Reply Last reply Reply Quote 1
                      • First post
                        Last post
                      The Community of users of the Notepad++ text editor.
                      Powered by NodeBB | Contributors