On 29/01/10 22:24, Ron Olson wrote:
Hi all-

Is there a particular way I can use to search for instances of null
(ascii 0, hex 0x0) in a file? I haven't come up with a way to do so,
yet there is clearly a null in my file as moving over it shows ascii 0
and hex 0x0, I just want to find/highlight all the others.

Thanks.


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


Best regards,
Tony.
--
Just because your doctor has a name for your condition doesn't mean he
knows what it is.

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

Reply via email to