• Login
Community
  • Login

How to highlight single line without caret going to next line

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
11 Posts 5 Posters 8.8k 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.
  • D
    Darkemis
    last edited by Feb 11, 2016, 10:43 AM

    Hello,

    Can someone please tell me how can I highlight only one line without caret going to next line. For example I’m trying to edit multiple lines scattered across a file but whenever I highlight a line and try to replace it via ctrl-h, the caret goes to the beginning of the next line and pulls up the line to the line I replaced making file broken.

    I’m new in all this as it can be noticed so please bear with me, thanks in advance!

    1 Reply Last reply Reply Quote 0
    • S
      Scott Sumner
      last edited by Feb 11, 2016, 1:24 PM

      This is just “how it works”. When what you describe occurs, N++ is blocking the entire line, including the line-ending. If you don’t want the line ending, simply decrease the width of the block by one position (usually shift+left arrow). This will move the cursor up to the previous line because it will now be between the last non-line-ending character and the line-ending.

      And, the behavior you “don’t like” is actually perfect when you are going to move the entire line somewhere else–you wouldn’t want an empty line replacing what is cut out (arguable, maybe you would), and where you paste it it would join with a line at the paste point, and I’m sure that would bug you too.

      In short, I think it is just something in N++ that you have to get used to. I did.

      1 Reply Last reply Reply Quote 1
      • D
        Darkemis
        last edited by Darkemis Feb 11, 2016, 10:51 PM Feb 11, 2016, 10:50 PM

        Right, I thought that might be the case. It’ll take a bit to get used to it and I can see how it can be useful in other cases, I just hoped there was a way to change how it works. Thanks for information on how it works.

        C 1 Reply Last reply Feb 11, 2016, 11:11 PM Reply Quote 0
        • C
          Claudia Frank @Darkemis
          last edited by Feb 11, 2016, 11:11 PM

          @Darkemis

          sorry, I don’t get what you were talking about and I’m curious what it is so
          excuse me while I’m stepping in and rephrase a bit.

          Can someone please tell me how can I highlight only one line without caret going to next line.

          By using SHIFT+END

          For example I’m trying to edit multiple lines scattered across a file but whenever I highlight a line and try to replace it via ctrl-h, the caret >goes to the beginning of the next line and pulls up the line to the line I replaced making file broken.

          But this means that your clipboard data has already the end of line chars (carriage return new line feed) added, meaning
          you selected it.

          As said, it might be that I’m completely wrong, but …

          Cheers
          Claudia

          1 Reply Last reply Reply Quote 0
          • D
            Darkemis
            last edited by Feb 12, 2016, 12:44 AM

            Basically what I wanted to know is if there is a way to select a line without automatically highlighting the end characters which make caret move to the beginning of the next line, because when I try to replace the line I intended it moves that line below it to the replaced one since end characters (which were hidden and I didn’t know about them) are highlighted and carried into replace tool.

            Sorry for confusion, I hope this clears it up a bit.

            1 Reply Last reply Reply Quote 0
            • C
              Claudia Frank
              last edited by Claudia Frank Feb 12, 2016, 1:05 AM Feb 12, 2016, 1:04 AM

              By using the keys SHIFT+END

              and you don’t have to excuse, I’m not a native speaker a simply didn’t understand it.

              Cheers
              Claudia

              1 Reply Last reply Reply Quote 0
              • S
                Scott Sumner
                last edited by Feb 12, 2016, 2:15 AM

                I may be remembering wrongly because I’ve used N++ so long, but I think that in the editors I used before if your cursor was in column 1 and you pressed Shift+DownArrow, the entire line was blocked in inverse video but the cursor remained at the end of the line it started on and not the next line (as N++ does it). I think that is what the OP didn’t like, and I tried to help explain and make the OP feel better about how it works in N++ in my earlier reply.

                C 1 Reply Last reply Feb 12, 2016, 4:44 PM Reply Quote 0
                • C
                  Claudia Frank @Scott Sumner
                  last edited by Feb 12, 2016, 4:44 PM

                  Hi Scott,

                  you are right, when I used npp the first time, long long time ago, this was one of the things which drove me crazy - but then I found the SHIFT+END ;-))

                  Cheers
                  Claudia

                  1 Reply Last reply Reply Quote 0
                  • W
                    William B
                    last edited by Mar 25, 2016, 6:36 PM

                    I have the same need, but for a different reason.

                    When I want to hide some lines, I click in the line numbers margin area for the first line, drag to the last line I want to select, and then hit Alt-H to hide the lines. Problem is that an additional line beyond the ones I selected gets hidden, because the caret had moved down to the beginning of the next line. Yes, I could hit Shift-Left first, but that seems a bit awkward.

                    I do appreciate Scott’s & Claudia’s point about the OP’s issue (as long as the REPLACE text includes the EOL, then it’s advantageous to have the selection-driven FIND text do the same).

                    So maybe my problem is less an issue of how Selecting works and more about the way Hide figures out its target?

                    Any thoughts/suggestions would be appreciated.

                    C 1 Reply Last reply Mar 25, 2016, 11:07 PM Reply Quote 0
                    • C
                      Claudia Frank @William B
                      last edited by Mar 25, 2016, 11:07 PM

                      Hello @William-B,

                      if I understood correctly you could

                      • click on the line margin
                      • press shift and then
                      • click last position of the last2hide line.
                      • alt+h

                      Cheers
                      Claudia

                      1 Reply Last reply Reply Quote 0
                      • G
                        guy038
                        last edited by Mar 26, 2016, 10:11 PM

                        Hi, Darkemis, Scott and Claudia,

                        Thanks Claudia and Scott to make us remember about the difference between the two shortcuts Shift + Down arrow and Shift + End ! A very little thing that may, sometimes, speed up our N++ work :-)

                        So, when cursor is at the very beginning of a line ( column 1 ) :

                        • Shift + Down arrow selects all the contents of this line, WITH its End of Line character(s)

                        • Shift + End selects all the contents of this line, WITHOUT its End of Line character(s)

                        Cheers,

                        guy038

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