Are printed line numbers all or nothing?
Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard
-
- Posts: 5
- Joined: Fri Apr 21, 2006 3:42 pm
Are printed line numbers all or nothing?
I'd like to print a file with line numbers, but don't need every one. Is it posssible to set it to only print every 5th line number?
- talleyrand
- Posts: 624
- Joined: Mon Jul 21, 2003 6:56 pm
- Location: Kansas City, MO, USA
- Contact:
Are printed line numbers all or nothing?
First, add an extra blank line at the beginning of your program.
This will be "line 0", which can be removed afterwards.
Then Find and Replace the following:
Find : (^.*)\n(^.*)\n(^.*)\n(^.*)\n(^.*)\n
Replace : \i(0,5)######\1\n######\2\n######\3\n######\4\n######\5
Note: Use POSIX syntax
I put hashes to indicate blank spaces. Please replace them before running. They are there to give a nice indentation to the result. Change as needed.
After running this, delete "line 0".
This will work through the whole of the text, EXCEPT the last few (5) lines (depending on the line numbers).
You can correct that manually yourself.
I hope this solution is useful.
Maybe someone could refine it further for you.
Cheers,
Boris.
This will be "line 0", which can be removed afterwards.
Then Find and Replace the following:
Find : (^.*)\n(^.*)\n(^.*)\n(^.*)\n(^.*)\n
Replace : \i(0,5)######\1\n######\2\n######\3\n######\4\n######\5
Note: Use POSIX syntax
I put hashes to indicate blank spaces. Please replace them before running. They are there to give a nice indentation to the result. Change as needed.
After running this, delete "line 0".
This will work through the whole of the text, EXCEPT the last few (5) lines (depending on the line numbers).
You can correct that manually yourself.
I hope this solution is useful.
Maybe someone could refine it further for you.
Cheers,
Boris.
-
- Posts: 5
- Joined: Fri Apr 21, 2006 3:42 pm
Thanks, I changed the replace to which eliminated having to add an extra line at the beginning. Unfortunately, the indentation lines up only when there are the line number is 4 digits long.
Code: Select all
######\1\n######\2\n######\3\n######\4\n\i(5,5)##\5
Ah, of course.Thanks, I changed the replace towhich eliminated having to add an extra line at the beginning.Code: Select all
######\1\n######\2\n######\3\n######\4\n\i(5,5)##\5
Yes, the indentation is a problem.Unfortunately, the indentation lines up only when there are the line number is 4 digits long.
I initially tried with tabs (\t), but they have the same problem.
As someone said before, it would be nice to have the \i work with left-padded zeroes.