Repeat lines and add empty lines after every line
-
Hello.
I need two different things done.
I have a list like this:
A B C
The first formating I need it to convert to:
(Repeat each line three times)A A A B B B C C C
The second formating I need it to convert to:
(2 empty lines after every line)A B C
Is this easily possible with notepad++ or is it better to use another solution?
-
@johnny-johnson
Use find/replace for (regular expressions ON) for both tasks
Get three of each line:
FIND:(?-s).+\R
REPLACE WITH$0$0$0
Get three newlines after each line:
FIND:\R
REPLACE WITH:$0$0$0
Reference material: https://npp-user-manual.org/docs/searching/#regular-expressions
-
I noticed that the last line of the original list doesn’t get edited that way in both cases (at least on my end) - but of course I can do that manually easily ;-)
Thanks a ton - it helps me a lot! -
@johnny-johnson said in Repeat lines and add empty lines after every line:
I noticed that the last line of the original list doesn’t get edited that way in both cases (at least on my end) - but of course I can do that manually easily ;-)
That’s a common issue. Often solution providers will just ask for a new last empty line to be added before running the regex (REGular EXpression). This allows the regex to work as planned. The alternative is to plan for that situation and the regex becomes more complex looking, although still relatively easy to understand. The
\R
refers to all line endings, except the last line in a file doesn’t have this hence why it didn’t work on that original last line.A question for you, you asked for these 2 steps separately, was it your intention to be using these regexes independently? It is possible to combine the 2 steps into 1 regex.
Terry
-
@Terry-R said in Repeat lines and add empty lines after every line:
intention to be using these regexes independently
Yes, it was my intention to be using these regexes independently - so the ones provided @Mark-Olson are perfectly fine. It’s incredible how helpful and fast responding this community is - I haven’t seen that before. Thanks a lot to you all!