Hardware Reference
In-Depth Information
find all "Apple"
Set the line height to exactly 17 points?
set fixed line height 17
You can construct a macro with dozens or hundreds of commands like this, one after the
other, and it will execute them all with a single click.
I gave find all "Apple" as an example, but one of the most useful things you can do with
a macro is automate more elaborate find-and-replace procedures—or a series of them. Nisus
Writer Pro, like a few other apps mentioned in this topic, lets you use a pattern-matching
system known as regular expressions for finding and replacing text. (It can take those
expressions even further by applying styles to portions of the expressions—a highly unusual
feature.)
Any type of find or replace operation can go in a macro. For example, this macro line finds
any sequence of two or more return characters and replaces it with one:
find and replace '\\n\\n+', '\\n', 'Ea'
Note: The letters E and a at the end tell the macro to perform the find and replace
with two special options—using regular expressions, or PowerFind Pro, as Nisus Writer
Pro calls them ( E ), and replacing all the occurrences in the document ( a ).
This one finds any sequence of two capitalized words and underlines just the first one:
find and replace '([A-Z][a-z]+)( [A-Z][a-z]+)', '\\1\\2', 'Ea-iU'
Note:
The -i at
the
end
means
“case-sensitive
search”;
the U means
“attribute-sensitive replacement.”
Complex Macros
It's easy to make a macro that executes a series of simple commands, but you may want to do
fancier things. You may want to use variables, arrays, objects, functions, loops, if/then/else
conditionals, mathematical functions, string manipulation, and other sorts of things you'd
normally find in a “real” programming language. All that, and much more, is well within the
purview of Nisus Writer Pro macros too!
Search WWH ::




Custom Search