Friday, January 29, 2010

Re: search for null

On Fri, Jan 29, 2010 at 10:50:51PM EST, Tony Mechelynck wrote:

[..]

> In addition to all that has already been said in reply to this post, it
> helps to understand that the null is handled in a special way in Vim,
> because a null byte terminates a C string. Therefore, a null (0x00) is
> represented as a linefeed (0x0A) in Vim memory, and you don't see a
> linefeed because (at least on Unix/Linux and Dos/Windows, not sure about
> Mac OS9 and earlier) it terminates a line. This explains why a null is
> displayed as ^J in some places, ^@ in others, and why all of the
> following will enter a null (not only in Insert mode, but also on the
> command-line, including a / or ? search command line) (In all the
> following, if Ctrl-V does a paste on your system, use Ctrl-Q instead):
>
> Ctrl-V Ctrl-J
> Ctrl-V Ctrl-@
> Ctrl-V 000
> Ctrl-V 010
> Ctrl-V x00
> Ctrl-V x0A
> Ctrl-V o000
> Ctrl-V o012
> Ctrl-V u0000
> Ctrl-V u000A
>
> and why (in addition to using any of the above after a slash) any of the
> following will also search for a null:
>
> /[\d0]
> /[\d10]
> /[\x0]
> /[\xA]
> /[\o0]
> /[\o12]
> /[\u0]
> /[\u0A]
>
> See
> :help NL-used-for-NUL
> :help i_CTRL-V
> :help i_CTRL-V_digit
> :help c_CTRL-V
> :help /[
> then scroll (or read ;-) ) until a list of codes starting with \e
>
> and for Mac-format files
> :help CR-used-for-NL

Thanks for posting this & the pointers to relevant documentation..

I was seeing some very odd things re: \x0a & \x00 on my box.

CJ

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

No comments:

Post a Comment