Possible to adjust the REGEX for the select sentence/paragraph commands?

is there any way we can adjust the Select Sentence and Select Paragraph commands?

would love to be able to add a few parameters. If not possible, consider either adding some additional commands for select clause, select in quotes. It’s just a nice feature for faster editing since most changes I make are at the clause level, or often wanting to change something within quotes.

thanks for any feedback. as an alternative approach, if there is any feasible way to hack this with autohotkey i am open to suggestions, however i dont want to copy and paste to clipboard, thats just too messy and error prone.

Here are two AutoHotKey scripts generated by Copilot.

This first one selects text enclosed within quotation marks around the current cursor position:

#IfWinActive ahk_class QMainWindow ; Scrivener's main window class
^q:: ; Assign Ctrl+Q to trigger the script
    Send, ^{Left} ; Move cursor to the beginning of the word
    Send, ^{Shift}{Right} ; Select forward up to the next character
    Loop, Extract Function(Scripener WinAPICall}) ;Expands and selects
Return

The second AutoHotKey script is for selecting a clause, where “clause” is generally defined by punctuation like commas, semicolons, or periods:

#IfWinActive ahk_class QMainWindow ; Ensures the script runs only in Scrivener 3's main window
^c:: ; Assign Ctrl+C to trigger the "Select Clause" action
    Send, {Shift Down}{Left} ; Start selecting text to the left
    Loop ; Loop until a clause-ending character is found
    {
        Send, {Left} ; Move cursor left one character
        IfWinActive, Delimit Func ;Detects 
    }
}
    Send, {Shift Up} ; Release the shift key to end selection
Return

I haven’t tried either script, so let me know how they work for you.

1 Like

i dont think autohotkey can get text from scrivener. it would be necessary to move it to clipboard, calculate the length to move, and then simulate the required key presses. Its possible to do that way but hacky and potentially destructive.

i was wondering if perhaps i am wrong though and scrivener does somehow expose the text.

2 Likes

Yeah, I think you’re right. I tried several ideas and couldn’t get text into the clipboard in any of them. In my case, I use smart quotes, so I had to account for them as well as straight quotes. I got past that hurdle, only to fail because of the clipboard thing.

Someone more experienced with Scrivener would have to chime in on possible commands that might do what you’re after.

Why can’t you write an RegEx to do those things?
Scrivener support RegEx natively in its search functionality.

3 Likes