How to add, before every row with text, a new line with the same length but filled with spaces ?
-
The title says it all.
Imagine the lyrics of a song with no empty lines between the lines with text.
I would like to add, before each line of text, a new line with the same length of the following line of text but filled with spaces.
In this way, when I’ll start adding the chords symbols above each line of text I don’t have to type all the spaces between the chords and I could even activate the overwrite mode.I already know how to add empty lines but I can’t figure out how to read the length of an existing line and the rest.
Thank you.
-
@fabiospark said in How to add, before every row with text, a new line with the same length but filled with spaces ?:
I would like to add, before each line of text, a new line with the same length of the following line of text but filled with spaces.
First, pick a character that does not occur at the end of any line your text. I’ll use
@
below.Next, use:
Find what:(?-s)^.*?\S.*$
Replace with:$&@\r\n$&
to duplicate every line of text, with an@
at the end of the first copy.Now use:
Find what:(?-s)\S(?=.*@$)
Replace with: (a single space)
to change all the characters on the @-lines to spaces, and finally:
Find what:@$
Replace with: (empty – delete the space!)
to remove the@
signs. -
@Coises Thank you. That worked like a charm?
Is there a direct way to turn the three single steps into a macro?
Never mind, I recorded it.
Thanks.
fabio -
@fabiospark said in How to add, before every row with text, a new line with the same length but filled with spaces ?:
Is there a direct way to turn the three single steps into a macro?
Start recording a macro, run those three regex, stop recording macro, save current macro.
-
You wouldn’t need anything special if you simply turn virtual spaces on; this allows your caret to move beyond line-endings. If you type a character while your caret is in virtual space, spaces will be added from the existing line-ending out to the column of the caret.
-
Hello, @fabiospark, @coises, @Peterjones, @alan-kilborn and All,
@coises, I suppose that the second and third regex S/R can be combined in a single one. So, first, we run :
SEARCH
(?-s).+
REPLACE
$0@\r\n$0
Then, we execute :
SEARCH
(?-s).(?=.*@)|(@)
REPLACE
?1:\x20
An other possibility is to use the two successive regex S/R, below, which do not need any char to identify the lines to be filled with
space
characters :SEARCH
(?-s).+\R
REPLACE
$0$0
Then :
SEARCH
(?-s)(.)|\R.+\R
REPLACE
?1\x20:$0
If we suppose that we, first, select the blocks of lines needing modifications, here are the corresponding macros :
<Macro name="Duplicate lines with Spaces" Ctrl="no" Alt="no" Shift="no" Key="0"> <Action type="3" message="1700" wParam="0" lParam="0" sParam="" /> <Action type="3" message="1601" wParam="0" lParam="0" sParam="(?-s).+" /> <Action type="3" message="1625" wParam="0" lParam="2" sParam="" /> <Action type="3" message="1602" wParam="0" lParam="0" sParam="$0@\r\n$0" /> <Action type="3" message="1702" wParam="0" lParam="640" sParam="" /> <Action type="3" message="1701" wParam="0" lParam="1609" sParam="" /> <Action type="3" message="1700" wParam="0" lParam="0" sParam="" /> <Action type="3" message="1601" wParam="0" lParam="0" sParam="(?-s).(?=.*@)|(@)" /> <Action type="3" message="1625" wParam="0" lParam="2" sParam="" /> <Action type="3" message="1602" wParam="0" lParam="0" sParam="?1:\x20" /> <Action type="3" message="1702" wParam="0" lParam="640" sParam="" /> <Action type="3" message="1701" wParam="0" lParam="1609" sParam="" /> </Macro>
Or :
<Macro name="Duplicate lines with Spaces Version 2" Ctrl="no" Alt="no" Shift="no" Key="0"> <Action type="3" message="1700" wParam="0" lParam="0" sParam="" /> <Action type="3" message="1601" wParam="0" lParam="0" sParam="(?-s).+\R" /> <Action type="3" message="1625" wParam="0" lParam="2" sParam="" /> <Action type="3" message="1602" wParam="0" lParam="0" sParam="$0$0" /> <Action type="3" message="1702" wParam="0" lParam="640" sParam="" /> <Action type="3" message="1701" wParam="0" lParam="1609" sParam="" /> <Action type="3" message="1700" wParam="0" lParam="0" sParam="" /> <Action type="3" message="1601" wParam="0" lParam="0" sParam="(?-s)(.)|\R.+\R" /> <Action type="3" message="1625" wParam="0" lParam="2" sParam="" /> <Action type="3" message="1602" wParam="0" lParam="0" sParam="?1\x20:$0" /> <Action type="3" message="1702" wParam="0" lParam="640" sParam="" /> <Action type="3" message="1701" wParam="0" lParam="1609" sParam="" /> </Macro>
Best Regards,
guy038