Tuesday, October 26, 2010

Re: Copying and replacing chars of a line through a regex

Hi Fernando!

On Di, 26 Okt 2010, Fernando Basso wrote:

> On Oct 26, 6:13 pm, Fernando Basso <fernandobasso...@gmail.com> wrote:
>
> > Moreover, what if I wanted to make it paste above (in line 8)?
>
> Well, for that I came up with:
>
>
> :9global/^\w/t.|.-1substitute/./=/g
>
> However, I still don't understand where in that regex line it is
> implied to
> paste line 9 to line 10.

You are using the :t command together with the address .
This means you are taking the line selected by the :g commandน and copy
it below the current line.

Now if you want to copy the line above the current line, you would
change the target adress from the current line to 1-current line, which
can be expressed like this:
:t-
So your command would look like this:
:9global/^\w/t-|.-1substitute/./=/g
which can be simplified to this:
:9t8|s/./=/g


See
:h :copy
:h {address}}

น) In fact, for your use case, you don't need the :g command at all:
9t9 will do the same.

regards,
Christian

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