On Jun 29, 10:56 am, Taylor Hedberg <tmhedb...@gmail.com> wrote:
> Bee, Fri 2012-06-29 @ 10:39:54-0700:
>
> > 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?
>
> > /^\s*$/ find all blank lines (only zero or more whitespace)
>
> > j ??? what does this do?
>
> `,/^\s*$/j` is a command that will be executed on each line that matches
> the /\S/ pattern (that's how the :g command works: :g/pattern/command).
> So it will be executed on each line that contains a non-whitespace
> character.
>
> The actual command here is `j`, which joins lines. Like many ex
> commands, it can be prefixed with a range of addresses to indicate which
> line(s) it should apply to. A range consists of an address, then a
> comma, then another address. In this case, the first address is omitted,
> which means it defaults to the current line (in this case, the line that
> matched the /\S/ pattern). The comma separates this from the second
> address, /^\s*$/. These two addresses comprise the start and end lines
> for the join operation.
>
> So in a nutshell, this command finds every non-blank line in the buffer.
> On each of those lines (A), it searches forward for the next blank line
> (B), and joins each line in the range from A to B using the :j command.
>
> signature.asc
> < 1KViewDownload
Thank you.
My confusion, I was thinking the 'j' was the 'normal' version for line
down and was expecting the 'normal J' for join. Now I understand it is
':j' for join 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
No comments:
Post a Comment