Sunday, October 26, 2014

Re: how to join all lines in a paragraph?

On 10/26/2014 02:32 PM, Tim Chase wrote:
> You can use the :j command to join a range of lines which works
> nicely with the range "'{,'}" or with a :g command such that you
> could do things like
>
> :g/^\n\</+;'}-j

I understand how the above works, but I can't find justification
for it in Vim's help. I'd break it down as follows:

:g Begin "global" command
/^\n\</ Find blank line followed by start of word
+ Go forward one line to start of paragraph
; Set cursor to above-calculated start of range
'} Move to blank line after paragraph
- Go backward one line to end of paragraph
j Join lines in paragraph delimited by the range

But looking at ``:help :g``, I see:

:[range]g[lobal]/{pattern}/[cmd]

The analysis above requires some features of a full-bown "range"
(:help range) instead of just the ``/pattern/`` (:help pattern)
that is permissible according to the help for ``:g``. Am I
missing something here? I can't tell if the documentation for
the global command should be expanded to cover this
functionality beyond a simple pattern, or if the ability to use
range-like features is accidental and not supposed to be part of
the global command.

Thanks,
Michael Henry

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