Monday, May 20, 2013

Re: vim: format each long lines and insert just one break afterward

this look much simpler, quick and works great. good to learn!

On 05/19/2013 02:30 PM, Gary Johnson wrote:

> Putting those together with a visual-mode mapping yields this:
>
> :vnoremap ,bf :s/\(\s*\n\)\+/\r\r/<CR>gvgq


still, just for a learning purpose, I'm curious about what's wrong with
the following script?

since I'm satisfied with this solution and I want to make it an
easier bind, so I make this:

function! FormatBook(...) range
exec a:firstline . "," . a:lastline . "g/^/put_"
exec a:firstline . "," . a:lastline . "g/^/exec " . "normal! gqq"
exec a:firstline . "," . a:lastline . "s/^\s*\n\n\+/\r/"
endf

com! -range=% -nargs=* FormatBook :<line1>,<line2>call
FormatBook(<f-args>)
map ,bf :FormatBook<CR>


specifically, I want to learn what's the right way to re-write the
following line in a ranged func ?

exec a:firstline . "," . a:lastline . "g/^/exec " . "normal! gqq"



thanks!

regards
ping

--
--
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/groups/opt_out.

No comments:

Post a Comment