How to execute command Cursor To Next Paragraph from within a macro?

How to execute command Cursor To Next Paragraph from within a macro?

5
NewbieNewbie
5

    Apr 02, 2013#1

    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?

    6,686585
    Grand MasterGrand Master
    6,686585

      Apr 03, 2013#2

      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:

      Code: Select all

      PerlReOn
      Find MatchCase RegExp "(?:\r\n[ \t]*){2,}"
      IfFound
      Key RIGHT ARROW
      Key LEFT ARROW
      EndIf
      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.

      5
      NewbieNewbie
      5

        Apr 07, 2013#3

        Thanks Mofi.

          Apr 07, 2013#4

          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:

          Code: Select all

              PerlReOn
              Find MatchCase RegExp "(?:\r\n[ \t]*){2,}"
              IfFound
              Key RIGHT ARROW
              Key LEFT ARROW
              EndIf
          And I added

          Code: Select all

              PerlReOn
              Find MatchCase RegExp "(?:\r\n[ \t]*){2,}"
              IfFound
              Key RIGHT ARROW
              Key LEFT ARROW
              Key CTRL+T    
              EndIf
          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?

          6,686585
          Grand MasterGrand Master
          6,686585

            Apr 08, 2013#5

            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.

              Apr 12, 2013#6

              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?