2011/2/9 Peter de Ridder <[email protected]>

> Hi,
>
> Using vim do edit binary files isn't always that easy. With
> display+=uhex you can make unprintable characters show as hex, but the
> printable characters are still shown as normal characters. Using xxd
> so convert a file to hex gives a nice view of the file in both hex and
> printable characters. But editing is still a bit difficult even with
> hex editing helper scripts. e.g. insering or removing data isn't easy
> since all the xxd offsets number need to be renumbered.
>
> To make it easier for hex editing in vim I try the split hex editing
> in different parts which could be added to vim and be setup with a
> command e.g. :hexthis (like :diffthis for diffing). The parts I came
> up with are:
> - Show all characters (printable or unprintable) as hex.
> - Show unprintable characters as a dot.
> - Number lines with byte offsets.
> - Columnize every x bytes.
> - Enter characters as hex.
> - Join lines over eol and make eol editable as if it was a character.
> - Other features like vsplit and scrollbind are already present.
>
> I know some if these options can be either impossible or to hard to be
> reasonable but I put them in the list to be complete.
> I started on implementing a few of the parts. I added preliminary
> patches for them.
>
> I'm providing the preliminary patches so other people can test them,
> tell what is missing, give pointers in to right direction or provide
> ideas on further improvements. I'm interested in using these feature
> myself maybe others are interested too and maybe these can become part
> of the newer versions of vim, when completed.
>
> I'll explain the different parts a bit further:
> - Show all characters (printable or unprintable) as hex.
> Preliminary patch: hex-displaymode.patch
> A per window setting to display all characters as hex, making all
> characters 2 display cells wide. This can be used as main hex editing
> window. Like the hex data part of xxd. The patch adds window option
> 'displaymode'='hex'.
> - Show unprintable characters as a dot.
> Preliminary patch: hex-displaymode.patch
> A per window setting to display all unprintable characters as dots,
> making all characters 1 display cell wide. This way this can be setup
> with scrollbinding to the main hex editing window and have half the
> width. Since the main window will have characters of 2 wide and this
> window will have characters of 1 wide, so the wrapping and such will
> match and scrollbinding can be used. This setting is like the right
> printable character side of xxd. The patch adds window option
> 'displaymode'='dot'.
> - Number lines with byte offsets.
> Preliminary patch: hex-hexnumber.patch
> A setting like 'number' and the recent 'relativenumber' but instead of
> line number it shows line byte offsets. The +byte_offset feature
> provides the internals for this. Line the first column if xxd. The
> patch adds window option 'hexnumber'.
> - Columnize every x bytes.
> Experimental patch: hex-columnview.patch
> Columnize characters in groups of x bytes or multiple groups. And
> break a line at x bytes neither by inserting eol or dependant on the
> window width. Gives a better for of data in (mostly) the
> 'displaymode'='hex' window. The patch adds
> 'columnview'={break},{count},{count},... ('columnize' might be a
> better name?)
> - Enter characters as hex.
> Type only [0-9a-fA-F] to enter data. This could be handled by a script
> and doesn't need to be part of the c code base.
> - Join lines over eol and make eol editable as if it was a character.
> Make the eol act like it as a normal character and let the line breaks
> be fully handled by either 'wrap' or 'columnview'. As for now I don't
> see any option in vim which does something similar and it seems very
> hard to me if not impossible without breaking the core structure. I
> could also live without this part since the other parts would be a
> good enough improvement already. vim is still a text editor and not a
> full featured hex editor.
>
> Patches:
> hex-displaymode.patch: Base patch adding the +hex feature and the
> 'displaymode' window option. This should work on vim7.3 (It is based
> on 7.3-112).
> hex-hexnumber.patch: Aditional patch to add 'hexnumber' window option.
> hex-displaymode.patch needs to be applied.
> hex-columnview.patch: Aditional patch adding experimental window
> option 'columnview', this is know to break. hex-hexnumber.patch needs
> to be applied. I might have started in the wrong direction with this
> implementation, so I might need to start over with this one.
>
> Regards,
> Peter
>
> --
> You received this message from the "vim_dev" 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
>

thank you for you patch! I desired editing hex text in Vim in a long time.

hex-columnview.patch can't compile in VC2008, you add preprocessing routine
within a macro, and VC can not hand this.

change all
RET_WIN_BUF_CHARTABSIZE(curwin, curbuf, s, col
#ifdef FEAT_HEX
, sep
#endif
)
like macro to:
# ifndef FEAT_HEX
        RET_WIN_BUF_CHARTABSIZE(curwin, curbuf, s, col)
# else
        RET_WIN_BUF_CHARTABSIZE(curwin, curbuf, s, col, sep)
# endif

may resolve this problem.

but when I set columnview, Vim behaves strange. it usually only show one or
two line of text, and the nest of line are "@", I don't know why it happens.

and, maybe you can close the syntax highlights or add new highlights groups.
and, how to show the original text after the hex text, so as in a normal hex
editor?

-- 
You received this message from the "vim_dev" 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

Raspunde prin e-mail lui