Community
    • 登入

    Quick move back to caret after using scrollbar

    已排程 已置頂 已鎖定 已移動 Help wanted · · · – – – · · ·
    9 貼文 4 Posters 3.5k 瀏覽
    正在載入更多貼文
    • 從舊到新
    • 從新到舊
    • 最多點贊
    回覆
    • 在新貼文中回覆
    登入後回覆
    此主題已被刪除。只有擁有主題管理權限的使用者可以查看。
    • Alan KilbornA
      Alan Kilborn
      最後由 編輯

      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 條回覆 最後回覆 回覆 引用 0
      • Alan KilbornA
        Alan Kilborn
        最後由 編輯

        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 條回覆 最後回覆 回覆 引用 0
        • Claudia FrankC
          Claudia Frank
          最後由 編輯

          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 條回覆 最後回覆 回覆 引用 1
          • Alan KilbornA
            Alan Kilborn @Claudia Frank
            最後由 編輯

            @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 條回覆 最後回覆 回覆 引用 0
            • Claudia FrankC
              Claudia Frank
              最後由 編輯

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

              editor.verticalCentreCaret()  
              editor.scrollCaret()  
              

              Cheers
              Claudia

              1 條回覆 最後回覆 回覆 引用 0
              • Joe BonifaziJ
                Joe Bonifazi
                最後由 編輯

                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 條回覆 最後回覆 回覆 引用 4
                • Claudia FrankC
                  Claudia Frank @Joe Bonifazi
                  最後由 編輯

                  @Joe-Bonifazi

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

                  Cheers
                  Claudia

                  1 條回覆 最後回覆 回覆 引用 0
                  • Alan KilbornA
                    Alan Kilborn @Joe Bonifazi
                    最後由 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 條回覆 最後回覆 回覆 引用 1
                    • guy038G
                      guy038
                      最後由 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 條回覆 最後回覆 回覆 引用 0
                      • 第一個貼文
                        最後的貼文
                      The Community of users of the Notepad++ text editor.
                      Powered by NodeBB | Contributors