Im not new to vim, but I realize my huge ignorance when I read that
you can edit binary files with vim via xxd.

Wow, amazing. However On my first attempt to use it Im kind of
confused and running into some problems. I think probably because I
dont quite understand the nuances of working with binary files.

I have a file that is a .cab file. It has references to c:\WINNT
\system32\spool everywhere. This is find but I need to change the
WINNT to Windows.

I create a file say called template. I put in two strings \WINNT\ hit
enter few times and then enter \Windows\

I open the template and then go into xxd eg :%!xxd . This gives me ...

0000000: 5c57 494e 4e54 5c0d 0a0d 0a0d 0a0d 0a0d  \WINNT\.........
0000010: 0a0d 0a0d 0a0d 0a0d 0a5c 5769 6e64 6f77  .........\Window
0000020: 735c 0d0a 0d0a 0d0a 0d0a 200d 0a         s\........ ..

The reason I have the template file is so that I can cut and paste the
hex numbers into my global change strings.

Now I open my .cab file that I want to change. Then type :%!xxd

Now I paste the numbers from the template, carfully copying only the
numbers i want.

 :1,$s/5c57 494e 4e54 5c/5c 5769 6e64 6f77 735c/g

Problem is that this doesn really work. Some strings for example are
coming out

c:\windows\system3spool\
others
C:\Windowssystem32\

I thought that it would ignore the spaces and just change the strings
but it only changes some of the strings. It is slavishly looking for
the exact string (sure I guess thats what its suppose to do duuu). But
how can I get it to be more forgiving.

Im thinking I need to write something like....

1,$s/5c57 494e 4e54 5c/5c?57?69?6e?64?6f?77?73?5c/g

Although Im not sure. If you know what I mean. Can anyone tell me how
to resolve this problem. Maybe the search string is not quite righ as
well.

Thanks
Regards

-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Reply via email to