I just finished massaging the text of a book to create a random quote generator.
I started by getting a copy of the book in pdf. From here, I saved a copy to as text. I left it while it was doing its thing since it was taking its sweet time. I expected a monster of a text. However, the text was only about 500K.
I quickly deleted some of the page footer and page header text. Then the fun started.
The sentences were broken at what appeared to be random points. A sentence would start at one line and continue for a few lines on.
The solution for this problem was simple. First, one had to join all of the lines together with this nifty little substitution command, that I got from the link below:
g/$/j
The j joins the lines at the matched character. I don't know what the g does. It would probably be a good idea to find out :P (I believe that it stands for global). http://vim.wikia.com/wiki/Joining_two_lines_of_text_based_on_pattern
I repeated this command until I only had a single line. From there, I ran the following substitution:
%s/\. /\r/g
Where \.[space][space] identified the end of a sentence. It just happened that the book ended up with this nice typographic pattern. To create line breaks in vim, one uses \r. \n, my natural choice, just enters a funky character, at least in windows. I learned this from the link below:
http://tech.petegraham.co.uk/2007/05/03/vim-search-and-replace-insert-ne...
And that was that.