Automatically close tags

Automatically close tags

3
NewbieNewbie
3

    May 23, 2007#1

    Hello

    Can i configure the UltraEdit 13.00, so that when i type the ">" of <html>, the close-tag "</html>" will automatically be added?

    I searched in the forums and at some searchengines, but i havent found help.

    Thanks for help!
    Daniel

    344
    MasterMaster
    344

      May 23, 2007#2

      You can write a simple small macro, that you can assign e.g. to "ctrl-shift->".
      Automatically would be strange. What happens if you really want to write <html> ?

      Macro looks like this:

      Code: Select all

      InsertMode
      ColumnModeOff
      HexOff
      UnixReOn
      Key Ctrl+LEFT ARROW
      "/"
      Key Ctrl+RIGHT ARROW
      ">"
      rds Bego
      Normally using all newest english version incl. each hotfix. Win 10 64 bit

      3
      NewbieNewbie
      3

        May 23, 2007#3

        First thanks for your help, but...
        Bego wrote:Automatically would be strange. What happens if you really want to write <html> ?
        When I write <html>, it would be nice when UE add </html> and but the cursor between <html> and </html>, so that I dont have to write the closing-tag.

        I write <html> and get <html></html>.

        Maybe you have not understood what I mean. My English is not that good.
        Daniel

        344
        MasterMaster
        344

          May 23, 2007#4

          Your description really was strange. But now I got you.

          Take this one:

          Code: Select all

          InsertMode
          ColumnModeOff
          HexOff
          UnixReOn
          Clipboard 9
          StartSelect
          Key Ctrl+LEFT ARROW
          Copy 
          EndSelect
          Key Ctrl+RIGHT ARROW
          "></"
          Paste 
          ">"
          Key Ctrl+LEFT ARROW
          Key Ctrl+LEFT ARROW
          Key Ctrl+LEFT ARROW
          Key RIGHT ARROW
          Clipboard 0
          EDIT: At my example, write "<html" without the > and then let it run.

          You can do similar with tags... somehow....

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

          3
          NewbieNewbie
          3

            May 23, 2007#5

            Thank alot Bego, that works nice!

            Daniel

            2

              Nov 22, 2007#6

              Code: Select all

              InsertMode
              ColumnModeOff
              HexOff
              UnixReOn
              ">"
              Find Up "<"
              IfFound
              Clipboard 9
              Key RIGHT ARROW
              SelectWord 
              Copy 
              Find ">"
              Key LEFT ARROW
              Key RIGHT ARROW
              "</"
              Paste 
              ">"
              Find Up "<"
              Key LEFT ARROW
              Clipboard 0
              EndIf
              
              Hey, I wrote this macro. It also works fine even if you have attributes in your tag. Try it.

              344
              MasterMaster
              344

                Nov 24, 2007#7

                Yes, even better :-)
                Normally using all newest english version incl. each hotfix. Win 10 64 bit

                1
                NewbieNewbie
                1

                  Jun 05, 2008#8

                  The last macro mentioned did not work so well for me (maybe because of changes in the newer version of UltraEdit), but it was close. Here's my version:

                  Code: Select all

                  InsertMode
                  ColumnModeOff
                  HexOff
                  UnixReOn
                  ">"
                  Find Up "<"
                  IfFound
                  Clipboard 9
                  Key RIGHT ARROW
                  SelectWord 
                  Copy 
                  Find ">"
                  Find ">"
                  Key LEFT ARROW
                  "</"
                  Paste 
                  Find Up "<"
                  Key LEFT ARROW
                  Clipboard 0
                  Find ">"
                  Key RIGHT ARROW
                  EndIf

                  2
                  NewbieNewbie
                  2

                    May 18, 2011#9

                    Hi,
                    Actually the recently opened tag gets closed but it is not closing the previous tag on the next execution of the Macro.
                    Kindly, update the coding asap

                    For EX:-
                    If we open <p> tag and <b> tag as below
                    <p> sample <b> document for reference

                    And when we apply the macro we get the output as
                    <p> sample <b> document for reference </b></b>

                    Here we need to close both the <p> and <b> Tags.

                    6,602548
                    Grand MasterGrand Master
                    6,602548

                      May 31, 2011#10

                      vastek, the macros posted here are designed for closing just the last tag. For a task like you posted a script would be necessary because with a macro that is impossible to realize. Even a script solution is hard to code because lots of other tags can be between the opening tag which should be closed and the current position of the cursor. Some of these embedded tags can be empty elements like <br> or <img src="...">, others can be block elements with closing tag optional in HTML, but required in XHTML like <li>, <p>, <td>, ... So the script would need to read in worst case entire structure of the entire HTML or XHTML file, interpret it depending on type of file, handle error conditions like missing closing tags or wrong order of closing tags (<b><i>...</b></i> is allowed in HTML, but not in XHTML) to finally find out if a closing tag is missing and which one.

                      BTW: UEStudio has this feature built-in. It's available in the HTML toolbar and has the name HTML Close Tag and which works also for XHTML and XML files. So if you need that often, you should think about upgrading from UltraEdit to UEStudio.

                      For UltraEdit there is also a script solution written by Rob Dawson and linked on Codebox Software - List of Pages with title UltraEdit Tag Completion Script.

                      2
                      NewbieNewbie
                      2

                        Jul 05, 2011#11

                        Dear Mofi,

                        Thanks for your reply and yes it is used only for closing last tag.

                        I got the required info. Thanks for your effort.