Duplicate Line not working as expected

Duplicate Line not working as expected

3
NewbieNewbie
3

    Jul 09, 2007#1

    Hello All,

    I am new to UE and have a problem with DuplicateLine command. It appears that DuplicateLine only works correctly if there is a 'Line terminator' present on the line you are trying to duplicate. For example if I type:

    Code: Select all

           This a test
    and immediately issue a DuplicateLine the results is:

    Code: Select all

           This is a test      This is a test
    It puts it on the same line. If I type in the same sentence and hit enter which puts a 'Line terminator' at the end and then issue the DuplicateLine command I get the following expected results:

    Code: Select all

           This is a test  
           This is a test
    The line is actually duplicated like I want. How can I get DuplicateLine to work regardless of whether there is a 'Line terminator' or not. This is a very common feature I use on a daily basis. Thanks.

    Ronnie

    6,686585
    Grand MasterGrand Master
    6,686585

      Jul 09, 2007#2

      A line must have a line termination or it is not a line. If the text at the end of a file does not end with a line termination, it is just a text (string) at the end of the file, but not a line.

      Here is a macro which automatically appends the line termination when executing it for duplicating the current line.

      InsertMode
      ColumnModeOff
      HexOff
      Key END
      IfCharIs 13
      Else
      IfCharIs 10
      Else
      "
      "
      Key UP ARROW
      EndIf
      EndIf
      Clipboard 9
      SelectLine
      Copy
      EndSelect
      Key UP ARROW
      Key DOWN ARROW
      Paste
      ClearClipboard
      Clipboard 0

      But this quick solution has 1 disadvantage: the cursor is always at start of the line after macro execution and not exactly at the same column in the new line as the command Duplicate Line does. I think, it cannot be better solved with a macro without special marking current cursor position before macro execution and run two replaces to delete this marker at the end of the macro to finally restore the cursor position. But that would produce additional undo steps which you maybe don't want.

      A better solution would be to convert this macro to a script. In the script environment it is possible to get the current column number and set the cursor at the end of the script to this column in the new line. But this requires UE v13.10 or higher.
      Best regards from an UC/UE/UES for Windows user from Austria

      3
      NewbieNewbie
      3

        Jul 10, 2007#3

        Hello Mofi,


        Thanks.......macro works fine with files that end with .txt (test.txt). But on files that have no extension like (test) it does not work. How do I associated this macro for a file with no extension. Thanks.

        Ronnie

        6,686585
        Grand MasterGrand Master
        6,686585

          Jul 10, 2007#4

          A macro does never depend on a file extension. This macro should be a part of a macro file which is automatically loaded during start of UltraEdit. The macro itself should have a hot key for fast execution. Whenever you want do duplicate a line, you can press this hot key and the macro will do the job independent of the line ending.

          I have tested the macro on a new edit window which content was never saved into a file and it worked.
          Best regards from an UC/UE/UES for Windows user from Austria