Selecting a Single Word
Page 1 of 1

Author:  bjast [ 2011-07-07 09:04:58 ]
Post subject:  Selecting a Single Word

Is anyone aware of a macro that will select the entire word by simply having the cursor placed somehwhere within that word?

This would make text editing a whole lot easier.


Author:  martin [ 2011-07-07 09:24:02 ]
Post subject:  Re: Selecting a Single Word

If you double-click any bit of text, the selection will expand to include the whole word that was clicked.

However, if you'd like to use a macro, here's one:
Send Selector ‘selectWord:’

That uses a bit of magic (Cocoa's "selectWord:" selector), and I was hoping for a more reusable example, but strangely our macro language is missing a "rangeOfWordAtIndex" command, which would be the most straightforward.

Here's another macro that also selects the whole word. It uses regular expressions, which may or may not be clearer for you:
Find Previous '\b', 'E'
Find Next '\w+', 'E'

Author:  bjast [ 2011-07-07 10:11:06 ]
Post subject:  Re: Selecting a Single Word

Thanks Martin.

As usual you came through with just what I needed.

This tip will be used by me many thousands of time in the coming years!


Page 1 of 1 All times are UTC - 8 hours
Powered by phpBB® Forum Software © phpBB Group