On 05/11/2010 01:08 PM, Jeri Raye wrote:
Hi
I have a large text file which I want to rearrange.
How to do that
I want
- every senstence on a single line, where a sentence is a line that
ends on a . or ." This is sentence can be in the orignal text file go
over several lines

What happens with abbreviations and non-period punctuation? "Is that Dr. Morales? She lives on Mimosa Dr. in my hometown!"

By your original rules, that's an incomplete sentence...

However, you should be able to get something like

  :%s/[.!?]\%(  \|\_$\)/&\r/g

to get you fairly close to what you expect, assuming sentence-ending-punctuation is terminated by two spaces or a newline.

Once you have that...

- Every space that's in a line must be counted, placed upfront the
line, and by the number + 1 needs to be done.

You can use the following:

:%s/.*/\=strlen(substitute(submatch(0), '\S\+', '', 'g')).' '.submatch(0)

to prepend the space-counts.

-tim


--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Reply via email to