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