Understanding Loop Descriptions in EmEditor

Asked 2 years ago, Updated 2 years ago, 351 views

Thank you for your help.
Repeat the conversion until the last line of this image.
I think the description is one time, and the rest is repeated until the last line.
If possible, I would like to enclose the original hiragana with the ●■ mark so that it remains in front of me even after conversion

After the conversion,
● Okinawa ■ Okinawa
● Kagoshima ■ Kagoshima

I look forward to your kind regards.
Enter a description of the image here

emeditor

2022-09-30 21:56

1 Answers

2021/4/2 Update-EmEditor v20.6.905 and above have improved the SendKeys method.Run the following macro only once:

Reconvert.jsee

 document.selection.Replace("^.+?$", "●\\0■\\0", eFindReplaceCase|eeReplaceAll|eeFindReplaceRegExp, 0);
document.selection.StartOfDocument(false);
while( document.selection.Find("?<=■).+?$", eFindNext | eFindReplaceCase | eFindReplaceRegExp, 0) {
    editor.ExecuteCommandByID (4199); // Reconversion
    shell.SendKeys("~");
}

EmEditor v20.6.904 and earlier

Unfortunately, the SendKeys method is not available for the EmEditor window itself that is currently running in the middle of a macro.If you try to use it, it will run all together at the end.

So why not use the following two macros as a compromise? In the first macro Reconvert1.jsee, copy each line enclosed by ■ such that Okinawa is ●Okinawa.

In the second macro Reconvert2.jsee, the string after the cursor position is reconverted and determined by the first candidate.Repeat this macro for a few lines.

Reconvert1.jsee

 document.selection.Replace("^.+?$", "●\\0■\\0", eFindReplaceCase|eeReplaceAll|eeFindReplaceRegExp, 0);
document.selection.StartOfDocument(false);

Reconvert2.jsee

 document.selection.Find("(?<=■).+?$", eFindNext | eFindReplaceCase | eFindReplaceRegExp, 0);
editor.ExecuteCommandByID (4199); // Reconversion
shell.SendKeys("~");

Sample after Recovert1.jsee

 ● Okinawa ■ Okinawa
● Kagoshima ■ Kagoshima
● Miyazaki ■ Miyazaki
● Kumamoto ■ Kumamoto
●Fukuoka ■Fukuoka
●Oita ■Oita
● but ■

Sample after seven Recovert2.jsee

●Okinawa■Okinawa
● Kagoshima ■ Kagoshima
● Miyazaki ■ Miyazaki
● Kumamoto ■ Kumamoto
●Fukuoka ■Fukuoka
●Oita ■Oita
● But ■ The difference is...


2022-09-30 21:56

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.