indent whole line?

indent whole line?

5
NewbieNewbie
5

    Apr 21, 2006#1

    Hi!
    Does anybody know how to indent a line wherever the cursor is at? For example (note: | is the cursor):
    (define abc
    (lambda () (+ 1 2 3)) |


    Then, pressing a key combination causes that line to be indented by one tab without me moving the cursor to the beginning of the line. (Note: ignore _, just to illustrate empty space cause HTML trims leading white spaces):
    (define abc
    __(lambda () (+ 1 2 3)) |


    And of course the vice versa. Really useful for programming, a feature in emacs I think (but I hate emacs, it's so confusing). Currently on trial version of UltraEdit v12. Thanks in advanced, I hope the example illustrates my question.

    13
    Basic UserBasic User
    13

      Apr 21, 2006#2

      Hello amazonpit,

      when you need to write formatted text in a post, you can use the code button, the one with the #; just select the text and press the button:

      Code: Select all

      (define abc
      
          lambda () (+ 1 2 3)) |
      I don't know exactly how to do what you want in a fast and clean way, there is an "Add Indent" function, but it requires to select the text, so it doesn't suits you; however, in my opinion, UltraEdit can do a quite good automatic indenting according with the file type you have if configured properly, maybe it could be another way of doing the same thing.
      Koko McCracken

      5
      NewbieNewbie
      5

        Apr 21, 2006#3

        Thanks for the prompt reply. Yea, I guess so. That feature is not essential, but it's a nice addition and I thought I asked if it exists already. Thanks for your help, I appreciate it.

        344
        MasterMaster
        344

          Apr 21, 2006#4

          OK , here we go:

          Make 3 macros:

          KEY_HOME:

          Code: Select all

          Key HOME
          IfColNumGt 1
          Key HOME
          EndIf
          LINELEFT1:

          Code: Select all

          InsertMode
          ColumnModeOff
          HexOff
          "XXXUNIQUEXXX"
          PlayMacro 1 "KEY_HOME"
          Key DEL
          Find "XXXUNIQUEXXX"
          Replace ""
          LINERIGHT1

          Code: Select all

          InsertMode
          ColumnModeOff
          HexOff
          "XXXUNIQUEXXX"
          PlayMacro 1 "KEY_HOME"
          " "
          Find "XXXUNIQUEXXX"
          Replace ""
          KEY_HOME is there to be sure to be at POS1 of the line, whatever UE settings are set.
          Bind those other 2 macros to e.g. Ctrl+Left Arrow / Right Arrow.

          Not the fastest one, but it works.

          BTW, it stuffes the line with BLANKS only. No tabs are respected.

          rds Bego
          Normally using all newest english version incl. each hotfix. Win 10 64 bit

          13
          Basic UserBasic User
          13

            Apr 21, 2006#5

            Hello,

            While having coffee this morning, I've come to this macro conclusion:

            Code: Select all

            InsertMode
            ColumnModeOff
            HexOff
            Clipboard 9
            StartSelect
            Key HOME
            Key HOME
            EndSelect
            Cut 
            "	"
            Paste 
            ClearClipboard
            Clipboard 0

            It's a cheap and easy macro, and do the trick quite well, however it's a bit late because Bego had the solution already, however, I need to share it :P

            God bless the coffee
            Koko McCracken

            5
            NewbieNewbie
            5

              Apr 22, 2006#6

              Wow, you guys are geniuses. :)

              Thanks a lot, exactly what I wanted. Awesome.

                Apr 22, 2006#7

                Is there a way to tell the macro to check if there's no tabs/spaces left in the first col, don't do the lineleft1?

                edit:
                nvm. figured it out. :D
                thanks anyway though.

                LINELEFT1

                Code: Select all

                InsertMode
                ColumnModeOff
                HexOff
                ":-:PROCESSING:-:"
                PlayMacro 1 "KEY_HOME"
                IfCharIs 9
                Key DEL
                EndIf
                Find ":-:PROCESSING:-:"
                Replace ""

                344
                MasterMaster
                344

                  Apr 22, 2006#8

                  Jup. That makes sense.
                  I didn't implement this because I can live with the "hard behaviour". Anyway it makes sense and should be done.

                  Hmmm, Maybe the performance is better with a short unique-string like "@#$" or sth. Lets try it out :-)

                  rds Bego
                  Normally using all newest english version incl. each hotfix. Win 10 64 bit

                  5
                  NewbieNewbie
                  5

                    Apr 22, 2006#9

                    Hey Bego, for the KEY_HOME macro:

                    Code: Select all

                    Key HOME
                    IfColNumGt 1
                    Key HOME
                    EndIf
                    Why does UltraEdit requires two execution of Key HOME to move cursor to beginning of line? Is that a bug or something?

                    6,675585
                    Grand MasterGrand Master
                    6,675585

                      Apr 22, 2006#10

                      At Configuration - Editor - Miscellaneous you can specify with Home Key Always Goto Column 1 how the HOME key works.

                      If this option is set, Key HOME sets the cursor always at column 1 and a single Key HOME in the macro is always enough. (That's the setting I always use.)

                      If this option is not checked (=default, I think) AND your current line contains preceding white-space characters (spaces or tabs), the first Key HOME sets the cursor to the first non-white-space character in that line. Now the cursor is already at the first non-white-space character and a second Key HOME sets the cursor to column 1.

                      But what happens when the cursor is already at the first non-white-space character before pressing the HOME key first time?

                      It isn't hard to guess. In this case the cursor is set with the first Key HOME to column 1 and a second Key HOME will set it back to the first non-white-space character. So the double Key HOME in the macro of Koko_McCracken will fail in this special situation too.

                      Only Begos' HOME macro makes sure, that the cursor is at column 1 independent of the configuration setting and if the current line has preceding white-space characters or not and where the cursor currently is.
                      Best regards from an UC/UE/UES for Windows user from Austria