Quick move back to caret after using scrollbar
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?
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.
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.
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! :)
Then you need to write a little script and assign a shortcut.
Content of the script
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.
this is a nice one - after reading your answer I remembered, oh yes - it’s that easy. :-)
Alan Kilborn last edited by Alan Kilborn
@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.
guy038 last edited by guy038
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 :
Now, you may, simply, read this reply just as an additional information on Scintilla commands about caret !!