Getting/Setting the caret position

Getting/Setting the caret position

2
NewbieNewbie
2

    Apr 16, 2009#1

    If there a way to display the numeric position of the caret in a file. I know the status bar displays the line number and column, but I need the absolute caret position. Also is there a way to goto an absolute position in a file.

    Thanks
    Neal

    236
    MasterMaster
    236

      Apr 16, 2009#2

      In Hex mode, the current byte offset is displayed in the status line.

      If you don't want to leave normal editing mode, you could place the caret at the position you're interested in, press Ctrl+Shift+Home to mark all characters until TOF, and then press Alt+^ (Word Count) to count all the characters inside the selection.

      For the other request (move to a certain position) I thought a Perl regex could do it: (?s)(?<=\A.{1000}) to find the position between the 1000th and 1001st character - which is a valid Perl regex but doesn't work in UE. Probably due to UE's line-based nature.

      2
      NewbieNewbie
      2

        Apr 16, 2009#3

        Thanks for your answer. Unfortunatly I need the text view rather than the hex view. Sadly using Shift home does not work as it does not return the absolute offset (in bytes). Instead it returns the number of visible characters.

        Neal

        6,602548
        Grand MasterGrand Master
        6,602548

          Apr 16, 2009#4

          Use Search - Character Properties. But take into consideration that you will not get the correct offset for UTF-8 or ASCII Escaped Unicode files because they are loaded with conversion to UTF-16 LE. Also a temporary conversion of UNIX/MAC line endings to DOS results in a wrong offset information in comparison to stored data.

          In text edit mode it is not possible to go to a specific byte offset.

          You can use also a script to get current position.

          Code: Select all

          var nPosition = UltraEdit.activeDocument.currentPos;
          UltraEdit.messageBox("Current position is: "+nPosition);
          But there is no command to go to a position in text edit mode, only in hex edit mode.