# Conflict of active strings in WinEdt

I am using WinEdt 10.2. I designed two active strings which do the following jobs.

One active string automatically changes "\c?}" into "\mathcal{?}" if ? is a single uppercase letter and does nothing if ? is not a single uppercase letter.

Another active string automatically changes "\f?}" into "\mathfrak{?}" if ? is a single uppercase letter and does nothing if ? is not a single uppercase letter.

Both active strings work find. But one day, I found that there is a conflict. When I typed "\chi{\fA}", I was expecting "\chi{\mathfrak{A}", but the active string was not activated since it matched the first one and the string between \c and } has more than one letters.

Is there a way to avoid this conflict?

(My idea to avoid the conflict would be to change the active strings into "\c{?}" and "\f{?}". I would like to know whether there is a solution still using the original active strings "\c?}" and "\f?}".)

Also I noted that for active strings in WinEdt the question mark ? stands for a string, instead of a single letter. I would like to know whether there is a wildcard which stands for a single letter.

I don't know how to tell WinEdt to disable the active string "\c?}" as soon as the string following \c has length more than one.

Q. I would like to know whether there is a solution still using the original active strings "\c?}" and "\f?}"

A. No, there is no solution. As you've noticed already, when you type "}" the first encountered active string is triggered, that is "\c?}".

Note that it is very unsafe to define such active strings, since it can trigger things like "\cite{someone}" as well. "\c{?}" and "\f{?}" are much safer.

Q. Also I noted that for active strings in WinEdt the question mark ? stands for a string, instead of a single letter. I would like to know whether there is a wildcard which stands for a single letter.

A. No. "?" is the only wildcard allowed in active strings definition and stands for "everything".

If you want to intercept only a single uppercase letter you should call a macro like this:

// -*- ASCII:EDT -*-

PushTagsandRegisters;

LetReg(0,"%?");
FindInString('%!0','<$Upper$~$~[]$',-11,-11,11);
IfOK('CharLeft;Backspace(2);Ins("mathcal{%!0");');

PopTagsandRegisters;

End;

In my opinion, it would be better, for your purpose, to use "abbreviations" instead of "active strings".

That is, in Abbreviations.ini, substitute the lines

SUB="END_LIST"
"etc"     -> "et cetera"
"\beg"    -> "\begin"
END_LIST

with

SUB="END_LIST"
"\cA}"    -> "\mathcal{A}"
...
"\cZ}"    -> "\mathcal{Z}"
"\fA}"    -> "\mathfrak{A}"
...
"\fZ}"    -> "\mathfrak{Z}"
END_LIST

where the dots mean that you have to repeat it for each uppercase letter.

Note that you have to change

ENABLED=0

to

ENABLED=1

in that file and then reload the script.

• Welcome (back)!
– Mico
Mar 11, 2018 at 9:50