Wednesday, January 27, 2016

Re: "Exploding" a paragraph into individual lines

2016-01-27 20:49 GMT+03:00 Chris Lott <chris@chrislott.org>:
> I'd like to take a paragraph like the following:
>
> This is a paragraph. Wow! What do I do now?
>
> And break it into individual lines, ala:
>
> This is a paragraph.
> Wow!
> What do I do now?
>
> StackExchange revealed this regex that seems to work well matching the proper lines:
> [.!?][])"']*\($\|[ ]\)
>
> So I can do this:
> :%s/[.!?][])"']*\($\|[ ]\)/XXX\r\r/g
>
> But obviously need something where XXX is!

This should be `\1`, while part before `\(` should be surrounded by
`\(\)`. And already existing `\(` should be `\%(` because you do not
need capturing here. You can also put `\zs` before `\%(`, in this case
`XXX` should be nothing, `\(\)` is also not needed.

>
> c
>
> --
> --
> 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
>
> ---
> You received this message because you are subscribed to the Google Groups "vim_use" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

--
--
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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment