Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Sign in to follow this  
Memfis

Insert blank lines after each X lines in text?

Recommended Posts

Yo, I was wondering, is there some easy way to insert a few blank lines after each X lines in text? Let's say I have:

aaa
bbb
ccc
ddd
Then I tell the program to instert 2 blank lines after each 2 lines and I get:
aaa
bbb
---
---
ccc
ddd
---
---
The reason I'm asking is because I broke the upper third of my ebook's screen so I can't read with it anymore. But maybe if I could insert blank lines just at the right places, then I could have the text always appearing at the bottom 2\3rds of the display, which works nicely, and then I could read again. Lol.

edit: or maybe it could be possible to edit the css style so that each page would start with a bunch of blank lines? But I dunno how that stuff works.

Share this post


Link to post

Pretty much any language could do that with a txt file etc. What type of file is it though, if its some proprietary weird file type it would be more difficult probably. Like it used to be hard to deal with gif file formats when that was proprietary. Do you have python 2.x installed?

Share this post


Link to post

Can you use Microsoft Word's Page Setup to setup margins for this e-book (you may be able to take screenshots of the pages, if nothing else)?

If this is plain text, another way is to learn Python programming…

Share this post


Link to post

I have a feeling that you could use some kind of CLI text manipulation program like "sed" or "awk" to do this for you, assuming you are using Linux, but it's just a hunch.

Share this post


Link to post

Correct.

awk '{print; if ((FNR % 20) == 0) { printf "\n\n";} }'
2 blank lines after every 20 lines.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  
×