>> I noticed “Go To Next Word, End” ignores words which are followed by
>> punctuation (except full stops) rather than a space:
> I took off my lazy hat and had a go rewriting the regex myself:
>
> tell application "BBEdit"
> find "(?<=\\w)\\b" searching in text of front text window options
> {search mode:grep, starting at top:false, wrap around:false,
> backwards:false, case sensitive:false, match words:false, extend
> selection:false} with selecting match
> end tell
>
> This does “Go To Next Word, End” for me. Am I missing something?
My first approach to this problem was identical to yours, look for the boundary
between a word character and a word border. But this is no different than using
the option-right-arrow shortcut.
I'm defining exactly what I think is punctuation should be, and where BBEdit
should move within it, instead of leaving it up to BBEdit. For example: with
the word "can't" your script (and BBEdit's built-in movement) moves between the
N and the apostrophe, mine moves to the end of the actual word.
You're right that my script could use some refinement. Specifically, I
(stupidly) hadn't accounted for commas, colons, semicolons, underscores, and
asterisks. I also hadn't accounted for punctuation inside brackets (etc)!
Here's the better version (I also improved movement at the end of the line):
tell application "BBEdit"
find "(?<=[\\w\\d]|$)(?=$|['\\\"][ )\\]}?!\\-\\.,;:\\*_$]|
|[)\\]}?!\\-\\.,;:\\*_])" searching in text of front text window options
{search mode:grep} with selecting match
end tell
--
--
You received this message because you are subscribed to the
"BBEdit Talk" discussion group on Google Groups.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
<http://groups.google.com/group/bbedit?hl=en>
If you have a feature request or would like to report a problem,
please email "[email protected]" rather than posting to the group.
Follow @bbedit on Twitter: <http://www.twitter.com/bbedit>