I am aware that in Word you can just triple click f8. But Pages has no such functionality. You can select words or paragraphs but not sentences. I am hoping there is a way to make KM do it, but so far I'm stumped. Ideas?
Shift-Option-Down Arrow on mine. I can’t remember if it was there all the time or if I set it in KM.
This selects all text from the location of the cursor to the end of the paragraph. It does not select a sentence. To be clear there is no existing hotkey for this in mac OS or pages. This is something that will have to be built. I'm guessing with a script -- But I'm unclear if this is the right approach or how to make it work.
I was using a external keyboard on iOS Pages and it worked when I tried it. On the Mac, I see you can also select a line forward with shift-cmd-right arrow. Also, you can use Shift-Down Arrow when your cursor is at the beginning of the line to select the full line. You will have to do more work because it doesn't stop at recognized period.
The whole list of Pages commands is here.
Good luck.
Yes, thank you, but I am fully aware of this list. I've used it a lot. None of these commands select a sentence. A line is different than a sentence.
It will likely not be a straight forward solution. This will not be as simple as appropriating an existing Pages command. That's why I'm here.
I am looking for someone who can help me build something in KM to select a sentence in Pages.
Wow... Good luck then...
Pages has an AppleScript interface.
If you have any questions (or requests) you can dm me.. I'm .. um.. rather familiar with it.
Some examples (from Sal)
https://iworkautomation.com/pages/body-text-basics.html
Hey, this looks like potentially a great approach! However, I've tried working with AppleScript in the past without much success and was a little confused as to how to integrate the script into KM.
I would love to message you directly but the site is not allowing me to due to the maximum number of posts being reached for a new user in a day. I'll see if I can follow up tomorrow. Alternatively, if you have any tips you can post publicly I would really appreciate it. Hopefully it will help someone else at some point too.
Unless you need to discuss something sensitive or contains private data, I'd encourage you to keep all of your technical discussions in the public forum areas.
This will help attract others who can contribute, and possibly solve your problem, as well as being a benefit to future readers who have the same or similar issue as you.
Sure, but he asked to be dm-ed. As he is helping me obviously I'm going to go along with his preference. Though you will see I also suggested a public approach.
As you're here, if you could help to solve the problem it would be greatly appreciated.
If I could have contributed I already would have. But I don't use nor know anything about Pages. If Pages supports RegEx, you might consider that. The problem is that the structural definition of a sentence is not well-defined, nor well-followed. If you can define some rules that you will always follow in your Pages text, then RegEx could be a good solution.
To get a feel for the challenge, see this Google Search.
I'm not very familiar with RegEx, but from a cursory search it does not look like it is supported by Pages. Otherwise, it looks like this might have been a useful solution and this info will be helpful for people looking to solve a similar problem in a different application.
Sorry to confuse folks, certainly we can ask/answer here. The second link I provided that shows in detail how to use AppleScript to query the document of a Pages doc should easily get you started. You can also get your current selection position, and find the sentence boundaries using a RegEx (as mentioned above).
Sorry, I'm confused, RegEx and Apple Script are all pretty new to me. If pages does support RegEx wouldn't this be a better way to go using KM? Or is there an advantage to AppleScript?
Also, I checked your AppleScript link but it only references 'word' and 'paragraph' keywords. How would I extract a sentence? Would I read backward from the cursor point until hitting a punctuation mark or paragraph break, then move forward to the first character, then highlight until I got to the next punctuation mark? This seems involved to want to make sure I have the right approach.
If so how do I identify the position of the cursor, I'm assuming the script starts reading from the top of the doc by default? Or does it start at the cursor? Is there a catch-all term for 'punctuation mark' and 'paragraph break' or are these defined separately?
Does RegEx work with AppleScript? I was given to understand they were distinct?
I appreciate that this isn't something anyone would be interested in doing for me, but does anyone at least know a good example to start with? At the moment I'm not even really sure what to search for.
Also if I do get the script written how would I integrate it with KM?
Thanks Micheal. @johns is suggesting that Pages will work with RegEx. If that's the case how do I implement it with KM? ie what macro/term/item would I use to do this? Do I need to extract the paragraph as a variable first? Or can RegEx read backward from cursor point?
@johns will have to show you how to use RegEx in Pages. AFAIK, there is no native RegEx support in Pages, and there is none in AppleScript. To use RegEx in AppleScript you have to either use a Scripting Addition like Satimage.osax (Free D/L & info at Smile companion osax ); OR use ASObjC (which is complex).
So, if there is no direct support in Pages for using RegEx to select text, then it would appear to me that you will need a very complex workflow/script to achieve it. Since you have limited experience with AppleScript, this could be a significant challenge.
As an alternative workflow, you might consider this:
Position the text cursor at the beginning of the sentence you want.
Then use one of these techniques:
- Press ⌥⇧→ to select one word at a time until you have selected the entire sentence.
OR - Press ⌥⇧↓ to select the remainder of the paragraph; Then press ⌥⇧← to deselect one word at a time until you are at the end of the sentence.
OR - Press ⌘⇧→ to select the remainder of the line; Then press either
- ⌥⇧← to deselect one word at a time, OR
⌥⇧→ to select one word at a time - until you have selected the entire sentence. until you are at the end of the sentence.
- ⌥⇧← to deselect one word at a time, OR
I use these macOS native keyboard shortcuts all the time, and they work well for me.
You might try these for a while to see if they will work for you, or if you want to spend the effort to write a complex script.
Thanks for this. I am also not seeing any evidence of RegEx support for AppleScript. At the moment I'm toying with a solution that I hope will be less complex than an AppleScript solution and less tedious than all that selecting. And remains native to KM. Though I'm not done yet so remains to be seen if I can get it working.
Generally, I'm thinking a workflow that:
- Selects from the cursor to the beginning of paragraph (there is a hotkey for this)
- Copies to this text to the clipboard
- Turns clipboard text into a variable -- this appears to make it manipulatable with RegEx
- Then select all text from last punctuation mark or paragraph break to the end of the line
- Save this text as a new variable
- Do the same for the second half of the paragraph, but save all text from the start of the line through the first punctuation mark as a variable
- Combine the latter two variable strings into another variable
- Part I'm struggling to logic through: Put these new variables back together in such a way that the third variable, which is the combination of the first and last part of the desired sentence, is selected. Then replace the original paragraph with this.
If you have any tips on the final series of steps, or any other points, I'm all ears. Hopefully, as this is a solution entirely native to KM the KM wizzes will have some good advice. There are so many KM tools, with so many hidden features, it's easy to overlook some potentially really great functionality and solutions. And being quite new it's not always obvious what to look at.
I was suggesting that you would use Applescript to get some bits of information that would be relevant:
- You could get the entire paragraph from where your current selection is
- You could then get the character range of that paragraph
- You could get the 'location' of your current selection (insertion point)
Back in KM, armed with that information, you can use RegEx to parse the paragraph into 'sentences', and loop over then sentence using the length of each string until you hit the one that has your insertion point. Then take that sentence.
In order to do this you'll need to have some basic understanding of AppleScript and RegEx
Here is a resource for breaking a paragraph into sentences which can be looped over using RegEx:
But how do you change the actual selection in Pages to be just the sentence?