Community
    • Login

    Character position

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    11 Posts 9 Posters 56.6k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Greg AmbroseG
      Greg Ambrose
      last edited by

      Is there a way to navigate to a specific column ( character position ) in a line of text. I have an error message in a program telling me that the error occur at line x, column 198. Icopied the text line to Notepad++ hopimg that I could easily identify the character at position 198.

      Can anyone help?

      1 Reply Last reply Reply Quote 0
      • Scott SumnerS
        Scott Sumner
        last edited by

        Well, what I would do if I needed to do this once or twice would be to put the caret on the line and then hold the right arrow key until the “Col:” in the status bar says “Col: 198”. Of course this seems so obvious maybe I am missing something.

        Steve LawsonS 1 Reply Last reply Reply Quote 0
        • Claudia FrankC
          Claudia Frank
          last edited by

          If this is the only line in this document you could do
          ctrl+home
          ctrl+g
          mark offset (needs to be done once only)
          type column number
          enter

          Cheers
          Claudia

          1 Reply Last reply Reply Quote 0
          • guy038G
            guy038
            last edited by guy038

            Hello Greg,

            Once again, regular expressions are very useful, concerning your problem :-)) Suppose that you get the warning : An error occurred, at line 38, column 198 !

            Simply, in the concerned document :

            • Get back to the very beginning of the file ( CTRL + Origin )

            • Open the Find dialog ( CTRL + F )

            • Select the Regular expression search mode

            • In the Find What zone, type (?-s)(.*\R){37}.{197}\K

            • Click on the Find Next button or hit the Enter key

            => A small calltip, with the indication ^ zero length match, appears, on line 38, at column 198 !

            Voilà !

            Notes :

            • Always locate your cursor at the beginning of your file, first

            • I wrote the two numbers 37 ( = 38 - 1 ) and 197 ( = 198 - 1 ). So, the general regex, to reach the column c of the line n, is (?-s)(.*\R){n-1}.{c-1}\K

            • The \K syntax, at the end of the regex, means that the regex engine forgets the selection of the 37 first lines, as well as the 197 first characters of line 38. So, that regex match a zero-length string, located between columns 197 and 198, of the line 38 !

            • The in-line modifier (?-s), at the beginning of the regex, forces the regex engine to consider the dot meta_character as a standard character, only, even if you, previously, checked the . matches newline option of the Find dialog

            Remark :

            • If your program contains leading tabulations, instead of spaces, that regex will NOT reach the correct location, as any tabulation counts for a single character, although it lies on 2, 4, … spaces !

            Best Regards,

            guy038

            古旮古 1 Reply Last reply Reply Quote 1
            • 古旮古
              古旮 @guy038
              last edited by

              @guy038
              hello guy038 ,
              I really want to know where to learn those regex syntax. The wiki page of notepad++ (http://docs.notepad-plus-plus.org/index.php/Regular_Expressions) contains several errors, and I don’t find the syntax “(?-s)” that you’re using. Where did you learn it?
              By the way, is there a way to sign in the wiki page, in order to edit the page? I only find “log in” on the upper-right, and don’t see how to register.
              I know I should’ve posted this whole thing in “General Discussion” of notepad++ community, but I have problem making “new Topic” at the moment. So I’m Replying here.
              Best regards.

              1 Reply Last reply Reply Quote 0
              • MAPJe71M
                MAPJe71
                last edited by

                The mentioned wiki page actually contains links to sites with the information you’re requesting.

                1 Reply Last reply Reply Quote 1
                • Shridhar KumarS
                  Shridhar Kumar
                  last edited by

                  Please check out my recently released plugin: GotoLineCol. If you have Notepad++ 7.8.3 or later, you should see this in the Plugins Admin list.

                  I need to review fixed-width format data files very frequently at work. So I set out to write this plugin to ease my workflow.

                  1 Reply Last reply Reply Quote 0
                  • Steve LawsonS
                    Steve Lawson @Scott Sumner
                    last edited by

                    @scott-sumner said in Character position:

                    Well, what I would do if I needed to do this once or twice would be to put the caret on the line and then hold the right arrow key until the “Col:” in the status bar says “Col: 198”. Of course this seems so obvious maybe I am missing something.

                    An example where your suggestion would not solve the problem. Occasionally a LibreOffice document becomes corrupted and thus can’t be opened. One way to fix this is to open the content.xml file and locate the position indicated in the Read Error pop-up message. Here’s a typical case of an indicated Row/Column: (2, 2826598). One would need to “hold down the right arrow key” for quite some time!

                    PeterJonesP 1 Reply Last reply Reply Quote 0
                    • PeterJonesP
                      PeterJones @Steve Lawson
                      last edited by

                      @steve-lawson said in Character position:

                      An example where your suggestion would not solve the problem.

                      Then use the plugin that was recommended two years ago (in the reply just before yours). Or write your own script for the PythonScript plugin which will allow you to go to that specific column… it wouldn’t be hard.

                      Steve LawsonS 1 Reply Last reply Reply Quote 1
                      • Steve LawsonS
                        Steve Lawson @PeterJones
                        last edited by

                        This post is deleted!
                        PeterJonesP 1 Reply Last reply Reply Quote 0
                        • PeterJonesP
                          PeterJones @Steve Lawson
                          last edited by

                          @steve-lawson ,

                          Then thank you for the information. And maybe someone else reading this in the future will appreciate my suggestion of using the PythonScript plugin to write a script to implement it in a different manner than the GotoLineCol plugin.

                          (BTW, it wasn’t my question, it was Scott’s.)

                          1 Reply Last reply Reply Quote 0
                          • First post
                            Last post
                          The Community of users of the Notepad++ text editor.
                          Powered by NodeBB | Contributors