Bill McCarthy wrote:
On Sat 27-Jan-07 11:15pm -0600, you wrote:
Ok, here is a question: Why not keep it the same, \n? Any reasoning behind
it?
That could be a way to do it, but that choice wasn't made.
Perhaps someone else could explain why \n means end-of-line
in the pattern, but nul in the substitution, while \r means
^M in the pattern, but end-of-line in the substitution? And
why not a \x representation for nul in the pattern - instead
of needing to do a [EMAIL PROTECTED]
[Note: ^M is created with ctrl-v following by <enter> and
^@ is created by ctrl-v followed by 000.]
IIUC, NULs are replaced by LF everywhere in Vim memory, because a NUL
terminates a C string while a LF is the only ASCII character guaranteed not to
exist (in Unix 'fileformat') in the middle of a line (as opposed to at its
end). So if lines are stored as C strings, substituting NUL for LF and
vice-versa allows representing everything. (Mac 'fileformat' may required some
fancy footwork; Dos 'fileformat' is handled by treating either CR+LF or LF as
a linebreak on input, and writing all linebreaks as CR+LF on output.)
Why not use the same character in "replace by" as in "search for" is harder to
explain, though. Maybe part of it is for historical "compatibility" reasons,
but it doesn't explain why that choice was made by whoever made it. It may
have something to do with the fact that hitting <Enter> at the keyboard
generates a CR but is stored (in memory) as a line break then (on file, if in
Unix 'fileformat') as a LF.
Best regards,
Tony.