On 11 Apr 2006, at 16:02, Allan Odgaard wrote:

Try this:

Ê1) Automation -> Start Macro Recording
Ê2) Edit -> Find -> FindÉ
Ê3) Enter this as search string: (?<![a-z])[a-z]+(?![a-z])
Ê4) Check the regular expression and ignore case checkboxes
Ê5) Click Previous and close the Find dialog
Ê6) Automation -> Stop Macro Recording

Now you have a macro which _selects_ the current word defined as only consisting of a-z.

Thanks Allan, this works a treat - I modified the regex to include numbers: (?<![a-z0-9])[a-z0-9]+(?![a-z0-9])

You can save this macro on any key you like, e.g. put it on option-W to signal Òmodified word selectionÓ.

Option-w creates this: · so I settled on ctrl-opt-w. Since repeated presses causes the selection to move backwards through words/word elements, I've actually recorded another version on linked keys to move forwards (shift-ctrl-opt-w).

You can give this (saved) macro a scope selector. For example if this is how you want word selections in CSS properties, give it a scope selector of meta.property-list.css or just source.css -- then you can record macros (with changed character sets) for other scopes and use the same key (and TM will pick the proper macro), or you can use different keys for different variants.

It's great that scopes can alter the behaviour of this depending on the type of content you're working on - I'll wait to see if I actually need to use this.

Perhaps there isn't the demand for this from elsewhere, but I would like to see my original suggestion implemented within TM at some point, as the macro approach does have some drawbacks in terms of expected or desired behaviour (Issues 1 & 2 are linked and probably fixable by modifying the macro):

1/ unlike ctrl-w, the current selection changes with repeated presses (though I've tried to make a virtue of this fact.)
2/ if at the start of the word/'word element' it selects the previous word or word element rather than the current one.
3/ cannot extend the selection to include the whole of the next 'word element' as you can do with words (using shift-opt-left or right.)
4/ cannot jump the cursor to the next 'word element' boundary - equivalent of cmd-left or cmd-right.
5/ cannot utilise mouse equivalents of selecting the whole word (double-click.)
6/ requires a change of mental context to switch to a command based keystroke rather than using current selection keys or mousing techniques with an additional modifier.

This probably 'ain't a priority', but I just wanted to suggest the idea so it was 'out'. After all, I already have a solution that does most of what I need (once again proving the power and flexibility of TM) and the full answer may lie in adding even more functionality to macros to obviate the issues I raised.

Thanks for the help and responses and thanks for listening.
James



James Andrews
Director

rÊeÊ -Ê cÊo g