• Login
Community
  • Login

Navigate to a specific record (tag)

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
4 Posts 4 Posters 3.2k 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.
  • P
    Peter Kirkwood
    last edited by Apr 28, 2016, 4:47 AM

    Hi all,

    I am a noob.

    When I use Fold All I get a folded view of all the records with the tag name.

    My question is this: If I have a total of 100 records and I want to jump to record 50 is there a better way to do this than I am currently doing which is count the records until I reach 50!

    Thanks

    1 Reply Last reply Reply Quote 0
    • G
      gerdb42
      last edited by Apr 29, 2016, 7:37 AM

      Two ways I can think of:

      1. Hit CTRL-g and enter the line number you want to jump to
      2. In Options->Preferences->Editing check “Display line numbers” and scroll to the desired line
      1 Reply Last reply Reply Quote 0
      • S
        Scott Sumner
        last edited by Apr 29, 2016, 11:35 AM

        I read the original poster’s question as more of “how do I easily jump 50 lines forward/backward from the line I’m currently on”, so I got to thinking about that. My first thought was that this would be very easy to implement with Pythonscript, but then I had an inspiration that regular expressions might help. Indeed they did, at least with a forward search:
        Find what: (.*\R){50}
        Search mode: Regular expression
        This will jump 50 lines forward from the current point in the file.

        1 Reply Last reply Reply Quote 0
        • G
          guy038
          last edited by Apr 29, 2016, 10:12 PM

          Hello, Peter, Gerdb42 and Scott,

          Very clever solution, Scott ! Indeed :-)) I slightly modified your main idea, to obtain the regex, below :

          (?-s)(?:.*\R){50}\K

          Notes :

          • The Regular expression search mode must be checked

          • The Wrap around option will be, also, checked ( IMPORTANT )

          • The (?-s) modifier ensure the DOT will NOT match any End of Line characters

          • The group (?:^.*\R) is considered as a NON-capturing group, because of the syntax, before the group, itself (?:. It, also, prevents from a non-wanted behaviour, while reaching the end of file !

          • Finally, the \K syntax forgets the previous match and matches an zero length string, only, as there’s nothing, following the \K form

          So, each time you click on the Find Next button or you hit the F3 key, you go at line 51, 101, 151, 201, and so on. The nice thing is that, when it remains less than 50 lines, near the end of file, it loops and get, again, the line 51 :-))

          • Unfortunately, the backwards search, with the shortcut SHIFT + F3, does NOT work :-((

          So, I thought about a second solution, which seems interesting, if you navigate throughout a huge file or if you frequently move forwards and backwards, as when building a source code ! This time, the right regex is :

          (?-s)(?:.*\R){50}\K\X

          Follow the few steps, below :

          • Open the Find dialog ( CTRL + F )

          • Select the Mark tab

          • Again, the Regular expression search mode must be checked

          • The Wrap around option will be, also, checked ( IMPORTANT )

          • Check the Bookmark line option ( IMPORTANT )

          • Click on the Mark All button

          • Close the Find dialog or use the ESC key

          • Now, you just have to hit :

            • The F2 key to go forwards, every 50 lines

            • The shortcut Shift + F2, to go backwards, 50 lines upwards

          As above, you reach the line 51, 101, 151, 201 and, towards the end of the file, loops back to line 51

          Notes :

          • Compared with the previous regex, the \X syntax has been added. Strictly speaking, the \X form stands for a unique non-diacritic Unicode character, followed by zero or more diacritic associated marks ( as simultaneous accents, on that character )

          • However, these details can be generally ignored and we may consider that, most of the time, \X represents, any single character, including the End of Line characters ! So this form avoids to write the longer regex (.|\R) :-))

          • So this regex marks the first character of a line, ( Normal character or End of Line character ), every 50 lines !

          Best Regards,

          guy038

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