[TxMt] Modifying word selection

Allan Odgaard throw-away-1 at macromates.com
Tue Apr 11 15:02:05 UTC 2006


On 11/4/2006, at 16:21, James Andrews wrote:

> This wasn't quite what I had in mind (more an extension of existing  
> keyboard or mouse text selection techniques using an added modifier  
> key) but it would be an alternative (and quick to implement) if it  
> could be made to work.
>
> What commands would you combine with the regex to result in  
> selecting text at the cursor with the specified scope? [...]

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.

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

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.




More information about the textmate mailing list