CR-used-for-NL

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

CR-used-for-NL

Andy Wokula

Minor issue, but somehow confusing:

Unix (and DOS (Win)) users know that Vim converts some characters when
reading and writing a file:

File <-> Memory <-> Display
NL       (NUL)      (line break)
NUL      NL         NUL (^@)

With ff=mac, Vim does another conversion, to keep NUL->NL:
CR       (NUL)      (line break)
NUL      NL         NUL (^@)
NL       CR         NL (^J)

Notation:
NUL     0x00
NL      0x0A
CR      0x0D

In parens:
(NUL)          assumption, might be temporary
(line break)   not an actual character

Assumption for correct behaviour: Displayed characters match characters
in the file.  If this is true then I've observed two bugs:

:h CR-used-for-NL
> When 'fileformat' is "mac", <NL> characters in the file are stored as
> <CR> characters internally.  In the display they are shown as "^M".
> Otherwise this works similar to the usage of <NL> for a <Nul>.
"                                                     WRONG - - - ^

Should be "^J".

Typing  ga  on ^J in the text (with 'ff=mac') prints
|   <^J>  13,  Hex 0d,  Octal 015
OK - -^   '- - - WRONG - - - - -'

Should be
|   <^J>  10,  Hex 0a,  Octal 012

gVim 7.2a BETA on Win32

--
Andy


--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: CR-used-for-NL

Bram Moolenaar


Andy Wokula wrote:

> Minor issue, but somehow confusing:
>
> Unix (and DOS (Win)) users know that Vim converts some characters when
> reading and writing a file:
>
> File <-> Memory <-> Display
> NL       (NUL)      (line break)
> NUL      NL         NUL (^@)
>
> With ff=mac, Vim does another conversion, to keep NUL->NL:
> CR       (NUL)      (line break)
> NUL      NL         NUL (^@)
> NL       CR         NL (^J)
>
> Notation:
> NUL     0x00
> NL      0x0A
> CR      0x0D
>
> In parens:
> (NUL)          assumption, might be temporary
> (line break)   not an actual character
>
> Assumption for correct behaviour: Displayed characters match characters
> in the file.  If this is true then I've observed two bugs:
>
> :h CR-used-for-NL
> > When 'fileformat' is "mac", <NL> characters in the file are stored as
> > <CR> characters internally.  In the display they are shown as "^M".
> > Otherwise this works similar to the usage of <NL> for a <Nul>.
> "                                                     WRONG - - - ^
>
> Should be "^J".

Depends on how you load the file.  But if you load it normally it's
indeed ^J.

> Typing  ga  on ^J in the text (with 'ff=mac') prints
> |   <^J>  13,  Hex 0d,  Octal 015
> OK - -^   '- - - WRONG - - - - -'
>
> Should be
> |   <^J>  10,  Hex 0a,  Octal 012

To make it consistent with what "ga" does on a ^J when 'fileformat' is
"unix", yes.

--
hundred-and-one symptoms of being an internet addict:
257. Your "hundred-and-one" lists include well over 101 items, since you
     automatically interpret all numbers in hexadecimal notation.
     (hex 101 = decimal 257)

 /// Bram Moolenaar -- [hidden email] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\        download, build and distribute -- http://www.A-A-P.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

RE: CR-used-for-NL

JohnBeckett
In reply to this post by Andy Wokula

Andy Wokula wrote:

> Minor issue, but somehow confusing:
>
> Unix (and DOS (Win)) users know that Vim converts some
> characters when reading and writing a file:
>
> File <-> Memory <-> Display
> NL       (NUL)      (line break)
> NUL      NL         NUL (^@)
>
> With ff=mac, Vim does another conversion, to keep NUL->NL:
> CR       (NUL)      (line break)
> NUL      NL         NUL (^@)
> NL       CR         NL (^J)

I've noticed some related confusion.

The command :dig has output including:
  NU  ^@  10
  LF  ^@  10  

However, if you actually use Ctrl-K N U in insert mode, then save the file, you will
get a zero byte (NUL). Same for Ctrl-K L F.

Of course ^@ is zero, so that's correct, and the 10 is how it's represented in
memory, so that's correct too. I guess it's unavoidable confusion.

John


--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: CR-used-for-NL

iler.ml
On Thu, Jul 17, 2008 at 2:08 AM, John Beckett <[hidden email]> wrote:
The command :dig has output including:
 NU  ^@  10

Inserting  Ctrl-K N U, then ga on it says  <^@>  0,  Hex 00,  Octal 000
Shouldn't :dig say
  NU ^@ 0
rather than  NU  ^@  10
?
 

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---