Hi,

Meino Christian Cramer wrote:
> From: Jürgen Krämer <[EMAIL PROTECTED]>
> Subject: Re: Copy a line of text without the LF
> Date: Tue, 08 Aug 2006 10:56:24 +0200
> >
> > Meino Christian Cramer schrieb:
> > >  I am using vim 7.0.42 on a Linux system.
> > >
> > >  I want copy a complete line of text *without+ the final LF at the
> > >  end, so it is possible to insert it elsewhere in the midth of text.
> > [snip]
> >
> > just use
> >
> >   y$
>
>  nice to now, that there is just another extra command... :)

it's not a command, it's a combination of a command (yank) and a motion
(to the end of line).

>  BUT: For what hopefully logical reason "y/$" does not work?

"/$" is a different motion than "$" -- in general, "/" as a motion puts
the cursor before the start of the matched text. As "$" is a zero-width
anchor and the cursor can't be positioned after the last character on a
line VIM uses the character before the match as "start of matched text".
Exception: With ":set virtualedit=all" the cursor can be placed beyond
the end of line and your command would have worked as expected.

>  And more
>  important: What is executed instead of one would extrapolate from
>  knowing y/<something other than $>.

Here again the cursor is put before the start of the matched text, e.g.,

  y/a

would yank up to but not including the next "a". If you want to include
the "a" you will have to use offsets, i.e. in this special case

  y/a/e

or more generally

  y/amore text/s+1

would include the "a". Have a look at ":help search-offset" for more
information on offsets in searches.

>  Or -- exaggerated to the limit -- do I need another extra command to
>  search/yank for example a "m" at line's end ???

  y/m/e

Regards,
Jürgen

-- 
Sometimes I think the surest sign that intelligent life exists elsewhere
in the universe is that none of it has tried to contact us.     (Calvin)

Reply via email to