Community
    • Login

    Quick move back to caret after using scrollbar

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    9 Posts 4 Posters 3.3k 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.
    • Alan KilbornA
      Alan Kilborn
      last edited by

      Is there a way to quickly move the caret back into the user-viewed region of a file, after using the vertical (or I guess also the horizontal) scrollbar with the mouse to view another section of a large file?

      Here’s a scenario in case that is unclear: Caret at line 100 of a 10000-line file. Use the scrollbar with the mouse to scroll so that line 8000 is visible. At this point I want to find the caret point, quickly (keypress to do this would be fine), putting the caret back in the user’s viewport. Is there a way?

      1 Reply Last reply Reply Quote 0
      • Alan KilbornA
        Alan Kilborn
        last edited by

        From a prior tip posted here, I thought of doing “undo” followed by “redo”. This will do what I want as long as there is something to undo. But if there isn’t then it does nothing. I’m seeking something that works under all conditions.

        1 Reply Last reply Reply Quote 0
        • Claudia FrankC
          Claudia Frank
          last edited by

          Alan,

          found out, recently, that scintilla has a function scrollCaret and
          it is also available as SCI_SCROLLCARET messages
          within shortcut mapper but hasn’t assigned a shortcut yet.

          So I guess this could be used if you assign a shortcut.

          Cheers
          Claudia

          Alan KilbornA 1 Reply Last reply Reply Quote 1
          • Alan KilbornA
            Alan Kilborn @Claudia Frank
            last edited by

            @Claudia-Frank

            Nice, Claudia. It doesn’t put the line of the caret in the CENTER of the viable region (which would be the BEST behavior for me), but it does make it viewable–I’ll take it! :)

            1 Reply Last reply Reply Quote 0
            • Claudia FrankC
              Claudia Frank
              last edited by

              Then you need to write a little script and assign a shortcut.
              Content of the script

              editor.verticalCentreCaret()  
              editor.scrollCaret()  
              

              Cheers
              Claudia

              1 Reply Last reply Reply Quote 0
              • Joe BonifaziJ
                Joe Bonifazi
                last edited by

                If I understand you correctly, what you are calling the caret, I call the cursor, but basically it is the insertion point if you type new text.
                Here is how I do this:

                Press Right arrow, Left Arrow. This moves the caret forward one char, back one char, and the display window is moved back to line 100.

                Claudia FrankC Alan KilbornA 2 Replies Last reply Reply Quote 4
                • Claudia FrankC
                  Claudia Frank @Joe Bonifazi
                  last edited by

                  @Joe-Bonifazi

                  this is a nice one - after reading your answer I remembered, oh yes - it’s that easy. :-)

                  Cheers
                  Claudia

                  1 Reply Last reply Reply Quote 0
                  • Alan KilbornA
                    Alan Kilborn @Joe Bonifazi
                    last edited by Alan Kilborn

                    @Joe-Bonifazi

                    @Claudia-Frank and I feel so silly now; of course you are right… :-D Typing a character and then hitting “Undo” also works as an alternative, but could be bad if a selection is active at the caret location.

                    In Notepad++ -speak and Scintilla-speak, the cursor is 99% or more of the time referred to as the caret, so I try to stick with that nomenclature here.

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

                      Hi, @joe-bonifazi, @alan-kilborn, @claudia-frank and All,

                      Oh yes, I’m feeling quite silly too ! Joe, it’s just a very simple and clever solution :-D

                      Reading the initial Alan’s post, I wanted to point him out to my reply to @yaron , six months ago about :

                      https://github.com/notepad-plus-plus/notepad-plus-plus/issues/2471#issuecomment-255602837

                      Now, you may, simply, read this reply just as an additional information on Scintilla commands about caret !!

                      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