[TxMt] Modifying word selection

James Andrews james.andrews at re-cog.com
Tue Apr 11 14:21:04 UTC 2006


On 11 Apr 2006, at 13:46, Charilaos Skiadas wrote:

> On Apr 11, 2006, at 7:24 AM, James Andrews wrote:
>
>> In quite a number of development situations (Rails, CSS, PHP,  
>> XSLT, etc.), commands, variables and other elements are often  
>> written in the form xxx-yyy or xxx_yyy_zzz. I often find myself  
>> dealing with related entities of the form xxxxxxxxx-aaaaaa and  
>> xxxxxxxxx-bbb where I just want to select the xxxxxxxxx or aaaaaa  
>> portion quickly and easily to either replace it, copy it or enter  
>> it into the search buffer.
>>
>> Other uses relate to elements such as variables (with @ or $ at  
>> the start) or css colour codes (such as #f33456) where you want to  
>> select everything except the special character in order to copy or  
>> replace it. For example Photoshop doesn't include the # if you  
>> copy a colour, so replacing an existing colour in a CSS file is  
>> slightly more fiddly than I'd like it to be, and I find that when  
>> I'm working on a design I have to do this often.
>
> This sounds like it could be easily accomplished by a macro  
> recording an appropriate regexp search. If you have the standard  
> word selection include the underscores etc, you could create a  
> macro, bound to your favorite keypress, which does a backward  
> regexp search for a "(sequence of letters, preceded by a nonletter  
> and followed by a nonletter) or (a sequence of numbers, preceded by  
> a nonnumber and followed by a nonnumber)". So maybe something like:
> ((?<![a-zA-Z])[a-zA-Z]+(?![a-zA-Z]))|((?<![0-9])[0-9]+(?![0-9]))

Hi Haris,

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? I've done some thinking  
and digging around in case I'd missed something, but can't see how it  
could be done.

Thanks,
James



More information about the textmate mailing list