Selecting a Single Word

Get help using and writing Nisus Writer Pro macros.
Post Reply
bjast
Posts: 39
Joined: 2010-01-06 10:58:07

Selecting a Single Word

Post by bjast » 2011-07-07 09:04:58

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.

Thanks

User avatar
martin
Official Nisus Person
Posts: 4290
Joined: 2002-07-11 17:14:10
Location: San Diego, CA
Contact:

Re: Selecting a Single Word

Post by martin » 2011-07-07 09:24:02

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:

Code: Select all

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:

Code: Select all

Find Previous '\b', 'E'
Find Next '\w+', 'E'

bjast
Posts: 39
Joined: 2010-01-06 10:58:07

Re: Selecting a Single Word

Post by bjast » 2011-07-07 10:11:06

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!

Bill

Post Reply