Macro replacement for command Delete Next Word

Macro replacement for command Delete Next Word

2
NewbieNewbie
2

    Mar 11, 2011#1

    Hello,

    I would like to make a simple macro that does two things:

    Ctrl-Delete (the shortcut to delete the next word)
    Down Arrow

    That's all. Is this possible, the macro recorder doesn't seem to want to record Ctrl+DEL and when I enter Ctrl+DEL when manually building a macro that doesn't work either.

    Thanks for your time
    TwoPigs

    6,686585
    Grand MasterGrand Master
    6,686585

      Mar 11, 2011#2

      This macro should do what you want. The green code emulates Ctrl+Del in insert mode when caret is not at beginning or middle of a word.

      InsertMode
      ColumnModeOff
      HexOff
      UnixReOff
      IfSel
      Delete
      EndIf
      IfCharIs 13
      Delete
      ExitMacro
      EndIf
      IfCharIs 10
      Delete
      ExitMacro
      EndIf
      IfCharIs 32
      Find RegExp "[ ^t]+"
      Replace ""
      ExitMacro
      EndIf
      IfCharIs 9
      Find RegExp "[ ^t]+"
      Replace ""
      ExitMacro
      EndIf

      Find RegExp "[~^t^r^n ]+[ ^t]++"
      Replace ""
      Key DOWN ARROW

      2
      NewbieNewbie
      2

        Mar 11, 2011#3

        Wow - thanks megatons,

        My little two lines replaced by all that code!? The thing is that I want this macro to work regardless of the cursor being inside a word or not.

        You don't need to write another large macro, as I appreciate your time, I'll make due. However, ...
        * I would like to know why I can't put the "Ctrl-Del" shortcut sequence into a macro?
        * Are shortcuts not allowed in Macros?
        * Can I somehow modify or add a shortcut?

        Thanks again for your time.

        6,686585
        Grand MasterGrand Master
        6,686585

          Mar 11, 2011#4

          Well, all the macro code is to replace original behavior of EditDeleteNextWord in any situation as usual in insert mode (column mode turned off) plus the additional cursor down.

          IfSel
          Delete
          EndIf


          is for deleting current selection if something is selected as Ctrl+DEL does in this case.


          IfCharIs 13
          Delete
          ExitMacro
          EndIf
          IfCharIs 10
          Delete
          ExitMacro
          EndIf


          is for deleting the line termination if Ctrl+DEL is pressed with caret at end of a line (CRLF, or only LF, or only CR).


          IfCharIs 32
          Find RegExp "[ ^t]+"
          Replace ""
          ExitMacro
          EndIf
          IfCharIs 9
          Find RegExp "[ ^t]+"
          Replace ""
          ExitMacro
          EndIf


          is for deleting just all spaces/tabs up to next non whitespace character or line termination if the caret is positioned on a space or tab character.


          And the last block

          Find RegExp "[~^t^r^n ]+[ ^t]++"
          Replace ""
          Key DOWN ARROW


          is what you actually want, delete from current position of the caret everything up to beginning of next word or end of line.

          With that code blocks you see that even a simple command needs lots of code inside UltraEdit to work in every case. And that was surely not all. Well, the last 2 blocks could be replaced by a simplified version which would have the advantage to be independent of the regular expression engine.

          InsertMode
          ColumnModeOff
          HexOff
          IfSel
          Delete
          EndIf
          IfCharIs 13
          Delete
          ExitMacro
          EndIf
          IfCharIs 10
          Delete
          ExitMacro
          EndIf

          StartSelect
          Key Ctrl+RIGHT ARROW
          EndSelect
          Delete
          Key DOWN ARROW



          The Command list in the macro editor list all possible commands and selecting one command in this list results in displaying all possible parameters of this command in the Non-numeric parameters list. On help page opened with Help button all the commands with all possible parameters are also listed and additionally explained. As you can see, the command Key supports only a few caret (cursor) moving commands. It is simply by design not possible to run any command from within a macro by simulating pressing its assigned hotkey.

          1
          NewbieNewbie
          1

            Apr 01, 2014#5

            I used to be able to record the Ctrl+Del shortcut in Visual Studio until they dropped the macro recording capability in later versions.

            Microsoft Word still allows the control sequence to be recorded. Here is the content of the Word macro for deleting the next word, and then moving the cursor down one line.

            Selection.Delete Unit:=wdWord, Count:=1
            Selection.MoveDown Unit:=wdLine, Count:=1

            I would have thought that since the UE configuration/Key Mapping command EditDeleteNextWord is already defined as Ctrl+Del, the macro editor would understand it.

            I guess I'll try the long macro you published.

            Mike