• Login
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.
  • A
    Alan Kilborn
    last edited by Apr 24, 2017, 12:54 PM

    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
    • A
      Alan Kilborn
      last edited by Apr 24, 2017, 12:56 PM

      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
      • C
        Claudia Frank
        last edited by Apr 24, 2017, 1:17 PM

        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

        A 1 Reply Last reply Apr 24, 2017, 1:21 PM Reply Quote 1
        • A
          Alan Kilborn @Claudia Frank
          last edited by Apr 24, 2017, 1:21 PM

          @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
          • C
            Claudia Frank
            last edited by Apr 24, 2017, 1:27 PM

            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
            • J
              Joe Bonifazi
              last edited by Apr 24, 2017, 1:33 PM

              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.

              C A 2 Replies Last reply Apr 24, 2017, 1:43 PM Reply Quote 4
              • C
                Claudia Frank @Joe Bonifazi
                last edited by Apr 24, 2017, 1:43 PM

                @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
                • A
                  Alan Kilborn @Joe Bonifazi
                  last edited by Alan Kilborn Apr 24, 2017, 1:56 PM Apr 24, 2017, 1:54 PM

                  @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
                  • G
                    guy038
                    last edited by guy038 Apr 24, 2017, 6:28 PM Apr 24, 2017, 6:27 PM

                    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
                    1 out of 9
                    • First post
                      1/9
                      Last post
                    The Community of users of the Notepad++ text editor.
                    Powered by NodeBB | Contributors