On 5/18/2013 5:33 PM, Gary Johnson wrote:
On 2013-05-18, ping wrote:
tested long time no good results...
so the goal here sounds simple: say I have
* a long text file (over 50K lines), and
* each line by itself is a nature paragraph, so sometime is very long
(over 1000 charactors).
* there are sometimes one of more empty line in between, sometimes not
I wanted to format it into:
1. if 2 lines are adjoining, add an empty line to as a break
2. if 2 lines already have more than 1 empty lines in between, remove
the extra and make sure only one empty line left.
This is equivalent to replacing a sequence of one or more newlines
with two newlines.
:%s/\n\+/\r\r/
3. trunk the long lines to multiple lines with each of 80 charactors
:set tw=80
gggqG
Regards,
Gary
Gary , thanks (again)!
I got it worked in these steps finally (sequence MATTERS):
1) :'<,'>g/.*/exec "normal! o\<esc>"
unconditionally insert a new line after each line (this may bring a lot
of empty lines , if the original book already contains empty lines)
2) format all each line seperately.
:'<,'>g/.*/exec "normal! gqq"
this is different than gggqG (this will mess up everything :D )
3) :'<,'>s/^\s*\n\n\+/\r/gc
use your method, delete all extra empty lines
--
--
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.