Reposition the Selection Toward the Top of the Editing Window

109 views
Skip to first unread message

Christopher Stone

unread,
Nov 24, 2021, 9:48:43 PM11/24/21
to BBEdit-Talk
On Nov 24, 2021, at 03:21, jj <goo...@mixio.com> wrote:
It only has effect once your text overflows the window because it takes advantage of the fact that, when jumping around, BBEdit repositions the current line at ± 25% of the window height.

On Nov 24, 2021, at 03:26, jj <goo...@mixio.com> wrote:
BTW, you should also set BBEdit Preferences > Editing > 'Extra vertical space ("overscroll") in text view' to 'Full Window'.



Hey Folks,

In the thread “Re: Typewriter mode possible?” JJ presents an AppleScript that adds a linefeed and repositions the working line toward the top of the document.

I repurposed it to scroll the currently selected text (or bare cursor position) toward the top of the document (the top 25%) and to retain the selection if there is one or the cursor position if not.

I've been wanting this for ages.

Thanks JJ!

I have some Keyboard Maestro macros that kludge repositioning the working line to the top, middle, and bottom of the document, but they are clunky.

I fervently wish BBEdit could do this natively.  The Z editor (a superset of Vi) on Windows could do this way back in the early 90's.  At the time I thought that was pretty slick but a little bit of overkill – I've since edited hundreds of thousands of lines of code and learned otherwise.


--
Best Regards,
Chris

--------------------------------------------------------
# Auth: Christopher Stone { Building upon work by Jean Jourdain }
# dCre: 2021/11/24 20:41
# dMod: 2021/11/24 20:41 
# Appl: BBEdit
# Task: Attempt to reposition the working line to the top 25% of the working document.
#     : Restores the cursor position or the selection if there is one.
# Libs: None
# Osax: None
# Tags: @Applescript, @Script, @BBEdit, @Reposition, @Cursor, @Selection
--------------------------------------------------------

try

    

    tell application "BBEdit"
        tell first window
            set selectedText to its selection
            tell its first document
                select insertion point after its text
                select selectedText
            end tell
        end tell
    end tell

    

on error aMessage
    display alert aMessage
end try

--------------------------------------------------------

Reply all
Reply to author
Forward
0 new messages