How to configure a hotkey for inserting tag <br> ?

How to configure a hotkey for inserting tag <br> ?

4
NewbieNewbie
4

    Nov 11, 2015#1

    It may be a dumb question, but I am breaking my head over how to configure a hot key for inserting the tag <br> into file. All answers are pretty vague or does not work, must be so simple imho :-(

    6,675585
    Grand MasterGrand Master
    6,675585

      Nov 11, 2015#2

      It is not simple as UltraEdit is a general editor not designed specific for HTML editing. But UltraEdit is highly customizable. Therefore it is of course possible to insert <br> by hotkey.

      I want to offer two solutions for inserting <br> by hotkey.


      1. Global template

      This solution is easy to configure. But it can't insert BR tag depending on file type as the other solution.
      1. Click in menu Advanced on menu item Display/Modify Templates.
      2. Select the Template group Global if not already selected.
        Hotkeys can be assigned only to the first 50 global templates.
      3. Click on button + below (empty) templates list and enter a template name like br.

        Why such a short name and not something longer?

        See the power tip about Smart Templates in case of you want to use this feature of UltraEdit and insert <br> tag via auto-suggest smart templates feature.
      4. In large Content edit field type <br> as text to insert.
        Press key RETURN if on inserting the tag also a line break should be inserted into the file.
        Optionally you can also enter a description like HTML line break tag.
      5. Click on button OK.
      6. Click in menu Advanced on menu item Configuration.
      7. Select in tree on left side the item Key Mapping.
      8. Navigate in Commands list to command InsertTemplate0 if this template was your first global template.
      9. Set input focus into edit field Press new (multi-)key.
      10. Press the hotkey you want, for example Alt + RETURN.
      11. Click on button Assign.
      12. Save modified setting and close configuration dialog with button OK.
      That's it. The template inserting the 4 characters with or without inserting also a line break can be called now by hotkey.


      2. Macro

      This solution is more difficult to configure. But it has the advantage that BR tag can be inserted into file depending on file type, i.e. as <br> for *.htm and *.html files and as <br /> for *.xht, *.xhtm and *.xhtml files.

      Here is the macro code for this smart inserting BR tag which you need to copy to clipboard.

      Code: Select all

      InsertMode
      ColumnModeOff
      IfExtIs "htm"
      "<br>"
      ExitMacro
      EndIf
      IfExtIs "html"
      "<br>"
      ExitMacro
      EndIf
      IfExtIs "xht"
      "<br />"
      ExitMacro
      EndIf
      IfExtIs "xhtm"
      "<br />"
      ExitMacro
      EndIf
      IfExtIs "xhtml"
      "<br />"
      ExitMacro
      EndIf
      The macro command IfExtIs makes a case-insensitive comparison of file extension of active file with the specified string.

      You can also add a default string in double quotes below last EndIf if BR tag should be also inserted if active file has none of the file extensions checked above, for example for using this macro also on new files.

      And it is also possible to insert together with the BR tag also a line break in active file by using following macro code.

      Code: Select all

      InsertMode
      ColumnModeOff
      IfExtIs "htm"
      "<br>
      "
      ExitMacro
      EndIf
      IfExtIs "html"
      "<br>
      "
      ExitMacro
      EndIf
      IfExtIs "xht"
      "<br />
      "
      ExitMacro
      EndIf
      IfExtIs "xhtm"
      "<br />
      "
      ExitMacro
      EndIf
      IfExtIs "xhtml"
      "<br />
      "
      ExitMacro
      EndIf
      Following steps are necessary to create this macro with a hotkey you want for fast execution, and being automatically loaded on startup of UltraEdit for usage at any time.
      1. Click in menu Macro on menu item Edit Macro.
      2. Click on button New macro.
      3. Type a macro name, for example Insert BR tag.
      4. Uncheck both check box options.
      5. Set input focus into edit field Hotkey.
      6. Press the hotkey you want, for example Alt + RETURN.
      7. Click on button OK.
      8. Select everything in large edit field on left side and press Ctrl+V to insert the macro code copied before in your web browser.
      9. Click on button Close and confirm updating macro with a click on button Yes.

        This single macro must be saved now into a macro file. A macro file can contain multiple macros. But I suppose you have not yet created any macro.
      10. Click in menu Macro on menu item Save All.
      11. Browse to a directory of your choice.

        I suggest entering or copying & pasting in file name edit field %APPDATA%\IDMComp\UltraEdit, hitting key RETURN to open this directory, clicking on icon to create a new folder in this directory and name this new folder Macros. Double click on this folder to enter this folder.

        Why creating such a folder in the application data folder of UltraEdit?

        All other UltraEdit configuration files used by you are also in this folder and its subfolders. Storing macro files also here makes it possible to backup and restore with Backup/Restore User Customizations in menu Advanced your macros together with the other configuration files.
      12. Enter now a file name of your choice, for example AutoLoaded.
      13. Click on button Save to save all currently loaded macros into specified macro file.

        Now it should be configured that this macro file with all its macros is loaded automatically on startup of UltraEdit.
      14. Click in menu Macro on menu item Set Auto Load.
      15. Browse to the macro file just saved.
        You could also enter or copy & paste %APPDATA%\IDMComp\UltraEdit\Macros\AutoLoaded.mac in file name field.
      16. Let the other options in the dialog unchanged and click on button OK.
      That's it. The file extension (file type) dependent solution for inserting BR is ready for usage.

      Extra hint: At Advanced - Configuration - Directories it is possible to define a default directory for macros which is automatically set when using Macro - Save All or Macro - Load or Macro - Load and Append to Existing.
      Best regards from an UC/UE/UES for Windows user from Austria

      4
      NewbieNewbie
      4

        Nov 11, 2015#3

        That's explaining as it should be, big thanks to you.
        I work a lot with PHP MySQL and HTML mixed in one file and not having a hot key for the <br> tag is slowing down coding a lot, but from now on it won't because I know now how to assign my own goodies ;-)

        Had PhpEd as an editor for one year now, but it cannot stand in the shadow of UE. My UE trial expired yesterday and bought it today so.

        UE great editor, great support thank you very much.

        Rob (chilm)

        3
        NewbieNewbie
        3

          May 24, 2016#4

          Just stumbled upon this post. You might find it easier to use a tool outside of UltraEdit.
          I use AutoHotKey (https://autohotkey.com/) for a ton of different stuff and it would easily handle this in one line.

          To make Alt-1 spit out <br> you would define it like this in AutoHotKey:
          !1::Send <br>