Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

By breaking into sentences I mean that each new sentence should start with a new line.

How to repeat )i<CR><Esc> to the end of the paragraph }? (<CR> = Enter)

If I make a macro )i<CR><Esc> as "q", can I execute it until the end of the paragraph?

share|improve this question
vap:s/\. /.^M/g
  • vap selects your current paragraph
  • :s/\. /.^M/g replace all periods followed by a space with a period followed by a newline. (Note that to get that literal newline (^M) in the replacement expression, you'll have to type <CTRL-V><CR>.)
share|improve this answer

You can do a search and replace. I just wrote this out. It works, but you could probably do better.

:%s/\v[ ]*([^\.]*\.)/\1\r/g
share|improve this answer

My solution, start in normal mode and type:

vip:'<,'>s/\n/ /|'<,'>s/\([.?!]\)\s/\1\r/g

Note that the first '<,'> will automatically be inserted on the command line when you press the ":" key after typing "vip" in normal mode.

The first substitute joins the paragraph into one line, then the "|" character delimits a second :-command within the same command line, and this time the "'<,'>" must be typed by hand. The second substitute command replaces a period, question mark, or exclamation mark followed by a space with the matching symbol and a newline.

This won't catch instances where a sentence ends with a period/excalmation/question and a quote character, etc. but the pattern can be extended to do so.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .