Why does the cursor movement command ALT+RIGHT ARROW not appear in the list of keyboard combinations supported by the 'KEY' macro command? ALT+RIGHT ARROW moves the cursor to the first non-blank character in the next paragraph. If I can't do this with the KEY command in a macro, how can I do it in a macro?
How to execute command Cursor To Next Paragraph from within a macro?
How to execute command Cursor To Next Paragraph from within a macro?
Yes, Alt+RIGHT ARROW by default assigned to command CursorToNextParagraph is not available as macro command. An alternate method to set the caret to first non whitespace character in next paragraph is:
The Perl regular expression Find searches for two or more DOS line terminators with zero or more spaces/tabs at beginning of every line. In other words it finds the whitespaces between last character of current paragraph and first non whitespace character of next paragraph. If such a whitespace block is found, moving the caret once right and left cancels the selection of the find and let the caret blink left of first non whitespace character at beginning of next paragraph.
Code: Select all
PerlReOn
Find MatchCase RegExp "(?:\r\n[ \t]*){2,}"
IfFound
Key RIGHT ARROW
Key LEFT ARROW
EndIf
Well, I thought I understood this but now I guess I admit I don't.
I just took the macro code you supplied in your example:
And I added
I expected the macro to position the cursor on the first non whitespace character in the next paragraph, then reformat that paragraph within the current column bounds (CTRL+T does that).
It does not work; no paragraph reformat occurs. If I type CTRL+T manually, outside a macro, it does reformat the paragraph.
Why?
I just took the macro code you supplied in your example:
Code: Select all
PerlReOn
Find MatchCase RegExp "(?:\r\n[ \t]*){2,}"
IfFound
Key RIGHT ARROW
Key LEFT ARROW
EndIf
Code: Select all
PerlReOn
Find MatchCase RegExp "(?:\r\n[ \t]*){2,}"
IfFound
Key RIGHT ARROW
Key LEFT ARROW
Key CTRL+T
EndIf
It does not work; no paragraph reformat occurs. If I type CTRL+T manually, outside a macro, it does reformat the paragraph.
Why?
In UltraEdit macros you can use only the commands which are listed in the editor and described in help of UltraEdit. Click on button help or press key F1 in the Edit/Create Macro dialog to open the help page with all available commands. The command Reformat Paragraph which you have assigned to key Ctrl+T is not available as macro command. You need to emulate this command with other macro commands like regular expression replaces.
The macro command Key does not emulate a user keyboard hit and therefore does not execute internal commands you have assigned to hotkeys. That cannot work as the macro interpreter would need to wait until the executed command is finished before continues with next command in the macro. When you execute Reformat Paragraph, you wait automatically before executing the next command.
Internal commands which require usually user interaction or user configuration are not available as macro commands as the result of the macro would be unpredictable because of depending on user interaction / configuration. Good written macros are independent on user settings.
The macro command Key does not emulate a user keyboard hit and therefore does not execute internal commands you have assigned to hotkeys. That cannot work as the macro interpreter would need to wait until the executed command is finished before continues with next command in the macro. When you execute Reformat Paragraph, you wait automatically before executing the next command.
Internal commands which require usually user interaction or user configuration are not available as macro commands as the result of the macro would be unpredictable because of depending on user interaction / configuration. Good written macros are independent on user settings.
BTW: Do you know that you can reformat all paragraphs in a file by simply selecting everything with Ctrl+A and executing Format - Reformat Paragraph?