P.S.: I’ve never had a problem with macros in ANY program because I’ve been using Macro Toolworks for almost 20 years now and have hundreds of well organized macros. Since Macro Toolworks provides macros at the Windows level, it can be used in all programs you use. I am sure there is an open source equivalent, but its name escapes me right now.

IMPORTANT : This post is OUT of DATE. Just refer to my updated next post, below !

Glad to know that Michael could help you, in that matter. Indeed, it’s the sensible solution : three short macros for adding emphasis to your RTF text.

But just for fun, I tried to imagine an other way with … a search/replacement, based on regular expressions ! ( Building regexes is just my besetting sin ! )

With the macro's method, you need to select, first, any range of characters to emphasize and, then, run the appropriate macro, one at a time.

With the S/R method, you would, just, have to mark with a special character the needed emphasis, while writing your text, and, then, perform this S/R, once only , at the end of the writing phase, which would write all the RTF formatting commands, in one go !

I, arbitrary, chose these three single characters, below, for each kind of emphasis :

The # character for bold emphasis

The @ character for italic emphasis

The % character for underlined emphasis

IMPORTANT : If you want to use any of the 14 characters, below, as a formatting sign, you’ll need to escape it, in the searched regular expression, with an antislash ( \ ) character !

. * + ? ( ) [ ] { } ^ $ | \

Then, I imagined TWO ways of placing these emphasis's signs :

Any word, expression or sentence, surrounded by TWO identical emphasis signs, would emphasize that word, expression or sentence

This #is an example# of text @with@ my emphasis %forms% to add !

Any emphasis sign, followed by a space character, located before a word, would emphasize ONLY this word !

This is an # second example of text @ with my emphasis % forms !

So, ONCE all your text, written with these NEW rules :

Go back to the very beginning of your document ( Ctrl + Origin )

Open the Replace dialog ( Ctrl + H )

In the Find what zone, type (?-s)(?|((#)|(@)|(%))([^ ].+?)\1|((#)|(@)|(%)) (\w+))

In the Replace with zone, type (?2/b\5/b0)(?3/i\5/i0)(?4/u\5/u0)

Select, at bottom, the Regular expression search mode ( IMPORTANT )

Click on the Replace All button

Et voilà !

=> You should have all the RTF formatting commands, added to all the ranges of characters, previously chosen :-))

Of course, you can save this search/replacement as a macro, as well !

For instance, from the text, below, which is part of the license.txt file, and which contains my emphasis marks :

The licenses for # most software are designed to take away @your freedom to share and change it@. By contrast, the %GNU General Public License% is intended to guarantee your freedom to #share and change free software#--to make sure the software is @ free for @ all its users. This %General Public License% applies to #most# of the Free Software Foundation's software and to @any@ @ other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to % your %programs, too%.

would be changed, in one go, into the text below :

The licenses for /bmost/b0 software are designed to take away /iyour freedom to share and change it/i0. By contrast, the /uGNU General Public License/u0 is intended to guarantee your freedom to /bshare and change free software/b0--to make sure the software is /ifree/i0 for /iall/i0 its users. This /uGeneral Public License/u0 applies to /bmost/b0 of the Free Software Foundation's software and to /iany/i0 /iother/i0 program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to /uyour/u0 /uprograms, too/u0.

Best Regards

guy038

P.S.,

In addition, with my regex method you can, perfectly, emphasize a part of a single word, only !

For instance the syntax h#on#@ey@-% moon would produce, after the S/R, the text h/bon/b0/iey/i0-/umoon/u0 :-))

When a formatting sign is preceded by an antislash character \ , NOTHING is changed => The formatting sign is considered as a literal sign, only ! And the antislash character is, of course, removed ( All cases from Test 07 to Test 18 ) :

Test 07 : \#word => #word
Test 08 : \@Any string with any special " ' ^ | character => @Any string with any special " ' ^ | character
Test 09 : \%A complete sentence, with many words => %A complete sentence, with many words
Test 10 : \# word => # word
Test 11 : \@ Any string with any special " ' ^ | character => @ Any string with any special " ' ^ | character
Test 12 : \% A complete sentence, with many words => % A complete sentence, with many words
Test 13 : word\# => word#
Test 14 : Any string with any special " ' ^ | character\@ => Any string with any special " ' ^ | character@
Test 15 : A complete sentence, with many words\% => A complete sentence, with many words%
Test 16 : word \# => word #
Test 17 : Any string with any special " ' ^ | character \@ => Any string with any special " ' ^ | character @
Test 18 : A complete sentence, with many words \% => A complete sentence, with many words %
Test 16 : wo\#rd => wo#rd
Test 17 : Any string with any special \@ " ' ^ | character => Any string with any special @ " ' ^ | character
Test 18 : A complete sen\%tence, with many words => A complete sen%tence, with many words

So, my previous original text, below, that I split in few lines :

The licenses for # most software are designed to take away @your freedom to share and change it@. By contrast,
the %GNU General Public License% is intended to guarantee your freedom to #share and change free software#--to make
sure the software is @ free for @ all its users. This %General Public License% applies to #most# of the
Free Software Foundation's software and to @any@ @ other program whose authors commit to using it. (Some other
Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it
to % your %programs, too%.

would be changed, with these new regexes, as below :

The licenses for \b most\b0 software are designed to take away \i your freedom to share and change it\i0 . By contrast,
the \ul GNU General Public License\ul0 is intended to guarantee your freedom to \b share and change free software\b0 --to make
sure the software is \i free\i0 for \i all\i0 its users. This \ul General Public License\ul0 applies to \b most\b0 of the
Free Software Foundation's software and to \i any\i0 \i other\i0 program whose authors commit to using it. (Some other
Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it
to \ul your\ul0 \ul programs, too\ul0 .

Concerning the 14 meta-characters, below ( not 13 ! ), which have a special meaning in regexes, I wanted to say : “If you intend to use any other formatting sign, than those I chose, which is one of these 14 meta-characters, you’ll need to escape it with an antislash character !”

. * + ? ( ) [ ] { } ^ $ | \

BTW, It’s just the case, in that second version, with the antislash character, itself, which is escaped by an second antislash !! If you forget this escaping sequence, in the searched regex , you’ll, probably, get the message "Invalid regular expression :-((

But, while building your text, except, of course, for the set[#@%], you can, simply, write any symbol as it ! ( I updated that list, in my previous post, too )

Hope that this second version looks fine to you :-))

Cheers,

guy038

P.S. :

Blair, as a word is, generally, followed with a space character, once the regex engine changes the ending formatting sign by the correct sequences, the parts "\b0", "\i0" and "\ul0" are, therefore, followed by TWO space characters ! Is the expected syntax that you would like to ?

Of course, if an ending formatting sign, is followed with a non-space character, the parts "\b0", "\i0" and "\ul0" are, normally, followed by one space character, only !