Navigate to a specific record (tag)



  • 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



  • 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


  • 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.



  • 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


Log in to reply