Friday, June 29, 2012

Re: please explain g/\S/,/^\s*$/j

On 2012-06-29, Bee wrote:
> Please explain HOW this works.
> g/\S/,/^\s*$/j
>
> I see it joins all lines by paragraph.
>
> g/\S/ find all lines that contain non-whitespace
>
> , ??? what does this do?

The comma (,) is a range separator. See

:help 10.3
:help [range]

> /^\s*$/ find all blank lines (only zero or more whitespace)

/\S/,/^\s*$/

specifies the range of lines from the first one containing a
non-whitespace character through the next line containing only
whitespace (possibly none).

> j ??? what does this do?

:help :j

It joins all the lines in the range.

The :g tells Vim to do this for all such ranges.

HTH,
Gary

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

No comments: