[SATLUG] searching for a hexvalue with vi

Kase Saylor h_oudini at hotmail.com
Thu Dec 20 15:46:34 CST 2007

Borries Demeler wrote:
>> I just opened up a binary file (in text mode) and tried searching for 
>> 'A0' first:
>> :%s/xa0
>> and it found 33 instances of 'A0' (displayed as 'A '). I then did a 
>> search/replace or 0x99 for 0xA0:
>> :%s/xa0/x99/g
>> And it replaced 33 instances. I then replaced 0x99 with 0xA0 and 33 
>> instances were replaced.
> Hmm, that's not the way it worked for me. 
>> When you actually press Ctrl-c you'll see '^', then when you type 'a' 
>> then '0', you'll see an 'A' and a ' '. When you press  x99, 
>> you'll see ''. Anyhow, that seems to work for me. Perhaps you could 
>> send a snippet of the file?
> Yes, that's very generous - I'm attaching a snippet. It has a few empty
> fields separated by a comma, but in 3 of them is another character embedded.
> If I move the cursor over it in vi and do a "ga" I get 
>     160,  Hex a0,  Octal 240 
> When I search for xa0 i'm not having any luck picking it up though.
> I appreciate your help, Kase!
> -borries
Well that is strange that you're not picking up A0 with you search, as I 
searched for it and found 4 instances. Here's exactly what I did
vi newfile
/Ctrl - C x a 0 [enter]

Here's a screen capture of the results:

vi capture


i’m is proud to present Cause Effect, a series about real people making a difference.

More information about the SATLUG mailing list