On Sep 13, 5:15 am, Drew Neil <[email protected]> wrote:
> Suppose I run "ayip to yank the following lines into register 'a':
>
>     one
>     two
>     three
>
> When I use the `:reg a` command to inspect the contents of the register, it
> shows newlines as ^J, like this:
>
>     --- Registers ---
>     "a   one^Jtwo^Jthree^J
>
> But if I use <c-r>a to paste the contents of that register at the command
> line, the newlines are represented as ^M, like this:
>
>     /<c-r>a
> expands to:
>     /one^Mtwo^Mthree^M
>
> Why does the newline appear as ^J in one case, and as ^M in the other?
>
> Thanks,
> Drew

It has done this for a long time, but it probably shouldn't. Your
original example shows how to unexpectedly fail to find a search for
text you just yanked from the buffer, but it messes up with editing
also. Observe:

one
two
three

"ayip
Gp

one
two
three
one
two
three

:let @a='<C-R><C-R>a'<CR>
Gp

one
two
three
one
two
three
one^Mtwo^Mthree^M

:let @a='one<C-V><C-J>two<C-V><C-J>three<C-V><C-J>'<CR>
Gp

one
two
three
one
two
three
one^Mtwo^Mthree^M
one
two
three

But, this also happens in version 6.1.5 (which happens to be installed
on a Solaris server here) so if it's a bug it's a very old one.

Note that using <C-R>a in insert mode will insert as intended no
matter which characters are used for line breaks. However, after
the :let command with the ^M characters, an extra line is appended due
to treating it as "linewise", even though it was already linewise and
did not need to be made even more linewise.

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

Reply via email to