On 28/12/08 04:19, bgold12 wrote:
> I've just discovered that the digraph for linefeed is always ^@, which
> is the same as the null digraph. This is confusing. Why not use ^J for
> linefeed, which would be more logical?
Vim internally uses the linefeed character to represent a null, so that
each line in memory is a proper null-terminated C string with no null
bytes in the middle: see ":help NL-used-for-Nul".
>
> Secondly, I've also discovered that the digraph for carriage-return is
> ^M when the fileformat is either dos or unix, but it changes to ^J
> when the fileformat is mac. Why is it like this?
Each of the three main platforms uses a different convention for
ends-of-lines: LF on Unix, CR on Mac, CR+LF on Dos/Windows. See ":help
CR-used-for-NL".
>
> Thirdly, I can't seem to get a linefeed displayed as a digraph
> character in vim at all. I've tried writing out a file in the unix
> fileformat, so that all newlines are LFs and there are no CRs, then I
> set the fileformat to mac (so that LFs should not be displayed as line
> breaks), I set fileformats to nothing, and I edit the file. I expect
> the LFs to be displayed as ^@ (meaning LFs), and I expect the :ascii
> command to return LF, but instead the LFs are displayed as ^J
> and :ascii returns CRs. Did vim convert the LFs to CRs when I edited
> the file?
Normally, when reading a file, Vim tries to guess which of the three
possible line endings were used in that file. The heuristic is governed
by the global option 'fileformats' (plural), and the particular value
used for a given file is remembered in the buffer-local option
'fileformat' (singular). You can also tell Vim which value to use by
means of the ++ff argument to some I/O commands, see
:help 'fileformats'
:help 'fileformat'
:help ++opt
But you seem to have read these already. See also the help tags for the
above two paragraphs.
Best regards,
Tony.
--
Nothing is illegal if one hundred businessmen decide to do it.
-- Andrew Young
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---