Inserting a string or tag multiple times at marked positions at once

Inserting a string or tag multiple times at marked positions at once

6,686585
Grand MasterGrand Master
6,686585

    Mar 16, 2010#1

    Update:
    The script below and everything I wrote about it is needed only for working with UltraEdit prior v21.00 or UEStudio prior v15.00. A multi-caret editing feature supporting also HTML/XML auto-completion was introduced with UE v21.00 and UES v14.10 making everything below obsolete.

    In some other editors it is possible to mark positions in a file and then type a text which is inserted at all marked positions at once. Sometimes it is even possible that the editor automatically detects if the inserted text is a HTML, XHTML or XML start tag and inserts at every second marked position the end tag. Such a feature does not exist in UltraEdit. But with the usage of following small script nearly the same can be achieved.

    Before using the script, the positions where to insert the string/tag must be marked in the file. To do this a character must be inserted which is normally not used in the files where this script is used. For example in most HTML, XHTML and XML files the paragraph character § is not present. The script as is expects that the positions where to insert the string/tag are marked with §.

    Now when running the script it first asks the user which string to insert and then inserts it either as simple text or as start/end tag pair. An example best demonstrates all possible variations.

    File content before running the script. | marks the cursor position.
    Input wrote:Here is a text to make §bold§, and here starts another §bold
    text§| which ends on the next line to test correct placement
    of the cursor after inserting the text/tags.
    With ' entered during script execution the result is:
    Output1 wrote:Here is a text to make 'bold', and here starts another 'bold
    text'| which ends on the next line to test correct placement
    of the cursor after inserting the text/tags.
    With <span style='font-weight:bold'> entered during script execution the result is:
    Output2 wrote:Here is a text to make <span style='font-weight:bold'>bold</span>, and here starts another <span style='font-weight:bold'>bold
    text</span>| which ends on the next line to test correct placement
    of the cursor after inserting the text/tags.
    But sometimes you may want to insert a single line tag. No problem, just append the marker character to end of the tag. For example with <br>§ entered during script execution the result is:
    Output3 wrote:Here is a text to make <br>bold<br>, and here starts another <br>bold
    text<br>| which ends on the next line to test correct placement
    of the cursor after inserting the text/tags.
    InsertStringMultipleTimes.zip (2.93 KiB)   186
    This ZIP archive file contains the second version of the script with comments and some hints for usage. First version was downloaded 185 times.