Tuesday, September 13, 2011

Re: Representing carriage returns in a register

On Tue, 13 Sep 2011, Ben Fritz wrote:

> On Sep 13, 1:48 pm, Ben Fritz wrote:
>> On Sep 13, 5:15 am, Drew Neil 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
>>>
>> 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.
>>
>
> Also in version 5.5.
>
> It would appear this is may be intentional. But I cannot imagine why.
>
>

^M == \r CR carriage return
^J == \n LF line feed

So, I think it's what's described at:

:help CR-used-for-NL
or
:help sub-replace-special

Maybe not the right explanation(s)... but I think it's the same reason:

\n sometimes means <NUL>, sometimes <NL>
\r sometimes means <NL>, sometimes <CR>

--
Best,
Ben H

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