Re: Inserting hex characters

2006-07-26 Thread Trent Gamblin
On Wed, 2006-07-26 at 21:53 +0300, Yakov Lerner wrote:
> If you add '-p' option to 'xxd' (see man xxd), like this:
>   au BufReadPost *.bin if &bin | %!xxd -p
> then you different hex format (without offsets) where
> you can easily add and remove bytes. The
> downside of 'xxd -p' format is, it doesn't show ascii part,
> only hex.
> 
> I think some other reversible convertors exist,
> (vis/unvis ?) that convert only unprintable chars and leave
> printable chars untact. In this conversion, it's easy to
> add and remove chars, too.
> 
> Yakov

Thanks for the info.



Re: Inserting hex characters

2006-07-26 Thread Yakov Lerner

On 7/26/06, Trent Gamblin <[EMAIL PROTECTED]> wrote:

On Wed, 2006-07-26 at 09:04 -0500, Tim Chase wrote:
> For doing binary editing in vim (a rare occurance, when I'm not
> just using a proper hex-editor), I tend to use the xxd that comes
> with the windows version (and is usually available on most Linux
> systems I've used) for transforming into an ascii representation
> of the hex, and translating back.  Details are found at

The problem I have with xxd is that I don't know a way to insert
and delete characters.


If you add '-p' option to 'xxd' (see man xxd), like this:
 au BufReadPost *.bin if &bin | %!xxd -p
then you different hex format (without offsets) where
you can easily add and remove bytes. The
downside of 'xxd -p' format is, it doesn't show ascii part,
only hex.

I think some other reversible convertors exist,
(vis/unvis ?) that convert only unprintable chars and leave
printable chars untact. In this conversion, it's easy to
add and remove chars, too.

Yakov


Re: Inserting hex characters

2006-07-26 Thread Trent Gamblin
On Wed, 2006-07-26 at 09:04 -0500, Tim Chase wrote:
> For doing binary editing in vim (a rare occurance, when I'm not
> just using a proper hex-editor), I tend to use the xxd that comes
> with the windows version (and is usually available on most Linux
> systems I've used) for transforming into an ascii representation
> of the hex, and translating back.  Details are found at

The problem I have with xxd is that I don't know a way to insert
and delete characters.



Re: Inserting hex characters

2006-07-26 Thread A.J.Mechelynck

Tim Chase wrote:

Careful, Tim: UTF-8 is unsuited to binary editing, because you
can't enter a byte >127 by itself in UTF-8.


True enough.  I tend not to use UTF-8, so I defer to your far
greater experience/knowledge on the matter.

For doing binary editing in vim (a rare occurance, when I'm not
just using a proper hex-editor), I tend to use the xxd that comes
with the windows version (and is usually available on most Linux
systems I've used) for transforming into an ascii representation
of the hex, and translating back.  Details are found at

:help hex-editing

-tim

PS: a belated welcome back to the list, Tonyhope you had a
relaxing time away.




When compiling Vim, on both Unix and Windows the default is to compile 
xxd together with Vim. It ends up under src/xxd. Under Unix, "make 
install" copies it to the same directory as the Vim binary (by default 
/usr/local/bin).


Yes, I had. You can see some photos I made over there by browsing to 
http://tonymec.deviantart.com/gallery/ (the latest-but-one photos in the 
gallery: the "Pujol d'Adalt" series). Click a thumbnail to enlarge it, 
then click the picture for full view.



Best regards,
Tony.


Re: Inserting hex characters

2006-07-26 Thread Tim Chase

Careful, Tim: UTF-8 is unsuited to binary editing, because you
can't enter a byte >127 by itself in UTF-8.


True enough.  I tend not to use UTF-8, so I defer to your far
greater experience/knowledge on the matter.

For doing binary editing in vim (a rare occurance, when I'm not
just using a proper hex-editor), I tend to use the xxd that comes
with the windows version (and is usually available on most Linux
systems I've used) for transforming into an ascii representation
of the hex, and translating back.  Details are found at

:help hex-editing

-tim

PS: a belated welcome back to the list, Tonyhope you had a
relaxing time away.


Re: Inserting hex characters

2006-07-26 Thread Trent Gamblin
On Wed, 2006-07-26 at 15:24 +0200, A.J.Mechelynck wrote:
> That is documented under ":help i_CTRL-V_digit", which we both 
> mentioned. Nulls are represented by linefeeds internally. To enter a 
> linefeed, break the line.

Sorry, should have read that first. Thanks again!



Re: Inserting hex characters

2006-07-26 Thread A.J.Mechelynck

Trent Gamblin wrote:

Thank you both for the reply. But when I type ^V010 or ^Vx0a it enters
<00> instead of <0a> (LF). Does anyone know why?





That is documented under ":help i_CTRL-V_digit", which we both 
mentioned. Nulls are represented by linefeeds internally. To enter a 
linefeed, break the line.



Best regards,
Tony.


Re: Inserting hex characters

2006-07-26 Thread Trent Gamblin
Thank you both for the reply. But when I type ^V010 or ^Vx0a it enters
<00> instead of <0a> (LF). Does anyone know why?



Re: Inserting hex characters

2006-07-25 Thread A.J.Mechelynck

Tim Chase wrote:

I'm editing binary files with Vim using "set display=uhex" and
I was wondering if there's a way to insert characters given
their scancode. Something like what I used to do in DOS by
holding Alt then typing the number of the character to enter?


Sounds like you're looking for what's described at

:help i_CTRL-V_digit

where you can, in insert-mode, type control+V followed by
-a decimal number
-an "x" followed by a hex number
-a "u" followed by a 4-hexchar unicode sequence
-a "U" followed by an 8-hexchar unicode sequence

HTH,

-tim



Careful, Tim: UTF-8 is unsuited to binary editing, because you can't 
enter a byte >127 by itself in UTF-8.



Best regards,
Tony.


Re: Inserting hex characters

2006-07-25 Thread Tim Chase

I'm editing binary files with Vim using "set display=uhex" and
I was wondering if there's a way to insert characters given
their scancode. Something like what I used to do in DOS by
holding Alt then typing the number of the character to enter?


Sounds like you're looking for what's described at

:help i_CTRL-V_digit

where you can, in insert-mode, type control+V followed by
-a decimal number
-an "x" followed by a hex number
-a "u" followed by a 4-hexchar unicode sequence
-a "U" followed by an 8-hexchar unicode sequence

HTH,

-tim







Re: Inserting hex characters

2006-07-25 Thread A.J.Mechelynck

Trent Gamblin wrote:

I'm editing binary files with Vim using "set display=uhex" and I was
wondering if there's a way to insert characters given their scancode.
Something like what I used to do in DOS by holding Alt then typing the
number of the character to enter?





In Vim it's not the keyboard "geographical" scan code (e.g. 1 for 
Escape) but the character value in alpha, hex, decimal or octal. Example 
for hex: Assuming 'fileencoding' (or, if the latter is empty, 
'encoding') is set to Latin1, not UTF-8:


^Vxhh

in Insert/Replace mode, or after hitting r (replace) in Normal mode, where:

  ^V  means "hit Ctrl-V", unless mswin.vim maps Ctrl-V to the paste 
operation, in which case it means "hit Ctrl-Q".

  x   is the lowercase letter iks.
  hh  is the hex value

You'll see the partial sequence near the bottom right of the Vim screen 
if 'showcmd' is on, and the character will appear in your file after you 
hit the 2nd hex digit.


See
:help i_CTRL-V_digit
:help i_CTRL-V


Best regards,
Tony.