Trying to code a "back tab"

Trying to code a "back tab"

25
Basic UserBasic User
25

    May 30, 2006#1

    Here's some macro pseudo-code I'm trying to assign to the Shift-Tab key:

    Code: Select all

    IfSel
    [do what Shift-Tab normally does if text is selected]
    Else
    [backspace twice]
    EndIf
    My goal is to prevent Shift-Tab from tabbing forward (which I find bizarre) but backspace twice, but only if text is not selected (i.e., I don't want to lose Shift-Tab's normal behavior of un-tabbing selected text, if any text is selected).

    As far as I can tell, this is not possible with the very limited macro language. Any tips are appreciated.

    Thanks

    Bill

      Jul 07, 2006#2

      It's been over 30 days and there are no replies, so I guess it's just not possible with UE's macro feature. (Does anyone else think that it's bizarre that Shift-Tab tabs forward?)

      I've written to IDM to request this seemingly simple feature. I guess we'll have to wait and see.

      Bill

      206
      MasterMaster
      206

        Jul 07, 2006#3

        I'm sure this isn't exactly what you want - maybe it's a starting point for discussion.


        InsertMode
        ColumnModeOff
        HexOff
        UnixReOn
        IfSel
        Find RegExp "^\t*"
        Replace All SelectText ""
        Else
        Key BACKSPACE
        Key BACKSPACE
        EndIf
        Software For Metalworking
        http://closetolerancesoftware.com

        25
        Basic UserBasic User
        25

          Jul 07, 2006#4

          Hi mrainey56,

          It looks like your macro will only work with "hard" tabs and will delete all leading tabs in the selected text. Nice try, though. I'd like to keep the editor's native Shift-Tab command if text is selected; otherwise, do a "back tab". It looks like UE's macro language isn't sophisticated enough to allow a macro to "chain" to a keystroke's native capability.

          Bill

          206
          MasterMaster
          206

            Jul 08, 2006#5

            This would work with hard tabs or spaces - it's set for four spaces, you could make it whatever number you like.

            Only deletes the first hard tab or first four spaces.

            Code: Select all

            InsertMode
            ColumnModeOff
            HexOff
            UnixReOn
            IfSel
            Find RegExp "^\t"
            Replace All SelectText ""
            Find RegExp "^    "
            Replace All SelectText ""
            Else
            Key BACKSPACE
            Key BACKSPACE
            EndIf
            
            Software For Metalworking
            http://closetolerancesoftware.com

            25
            Basic UserBasic User
            25

              Jul 10, 2006#6

              Hi mrainey56,

              Well done. This is closer to my desired behavior, but it has at least one undesirable side-effect: The most recent "find string" is the string specified in the macro. Is there any way to perform a find/replace in a macro without causing the find/replace MRU list to be updated?

              Also, it seems that this technique breaks down if the I change my tab width. (I still think it's bizarre that Shift-Tab does a forward tab.)

              Bill

              206
              MasterMaster
              206

                Jul 10, 2006#7

                I can't answer the MRU question. I seldom change the tab width.

                If I did change the tab width frequently, and wanted to use the macro, I might try sticking one of these lines at the top of my file:

                ~#1
                ~#2
                ~#4


                Basically, a couple of unique characters followed by the tab width. Use whatever unique strings are appropriate for you. Have as many possible tab widths as you like.

                The macro would first search for ~#1. If ~#1 was found, code to remove one tab or space would be executed, then the macro would end.

                If not found, the macro would do a search for ~#2. If ~#2 was found, code to remove one tab or two spaces would be executed, then the macro would end.

                Find ~#1
                IfFound
                do stuff for tab width of one
                ExitMacro
                EndIf

                Find ~#2
                IfFound
                do stuff for tab width of two
                ExitMacro
                EndIf

                And so on. It sounds klutzy, probably is, but might help with your problem.

                I'll leave it to you to play with the code, if you want to. If you can't get it to work, ask for help. If you find the concept revolting, sorry, it's my best shot right now.

                  Jul 10, 2006#8

                  I studied the idea a little more - probably too many gotchas to work out. Sorry.
                  Software For Metalworking
                  http://closetolerancesoftware.com

                  6,675585
                  Grand MasterGrand Master
                  6,675585

                    Re: Trying to code a

                    Jul 11, 2006#9

                    I have not posted anything to this thread till now because I simply can't understand what is the benefit pressing the 2 keys Shift+Tab instead of Backspace twice. I personally think that pressing the Backspace key twice is faster because easier to press than Shift+Tab.

                    However, the indent spaces can be also removed without a find/replace. But the solution would be extremly slow, because you have to copy the selected text into a new file, use a loop which removes the fixed number of indent spaces at very line of the text, selects the modified text, copies it, closes the new file and pastes it over the still selected text.

                    The macro code for unindenting a single line is available at Is there any shortcut to unindent a single line.

                    Also this solution has 2 problems. It works only for a fixed number of indent spaces and not tabs, if you do not write a better macro as the one mentioned above. And since UE v12.10+3 it will not really work because of the new focus handling when closing a file described at Problem with Previous Window/Tab Command, if you have more than 1 file open and your file is not the most right one in the open tab sequence.
                    Best regards from an UC/UE/UES for Windows user from Austria

                    25
                    Basic UserBasic User
                    25

                      Jul 14, 2006#10

                      Hi Mofi,

                      I appreciate your input, but there are just too many limitations in the UE macro "language" to be very useful. IMHO, the macro system needs to be based on a programming language that supports programming features such as variables, conditionals, loops, etc.

                      In any case, maybe you don't understand the big deal because you've gotten used to UE's limitations. Believe me, some of UE's behavioral characteristics (character-by-character undo, lack of undo for certain features, and lack of back tab are just a few) feel really bizarre when you've worked with other, more capable, editors.

                      Bill

                      206
                      MasterMaster
                      206

                        Jul 14, 2006#11

                        feel really bizarre when you've worked with other, more capable, editors.
                        I hope you found all this out during the free trial period. Which editor is your favorite?
                        Software For Metalworking
                        http://closetolerancesoftware.com

                        25
                        Basic UserBasic User
                        25

                          Jul 17, 2006#12

                          My long-time favorite editor is The SemWare Editor, aka TSE (http://www.semware.com/). It looks a bit odd (the GUI version looks like a text-based program), but it has a built-in programming language called SAL and a macro compiler. It supports multi-keystroke chords, sensible and consistent grouped undo, etc.

                          Bill