XXD with Vim

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

XXD with Vim

Ven Tadipatri
Hi,
  It's nice that you can go into hex mode with Vim through the use of XXD, but it's really hard
trying to find out what hex codes correspond to a given character. Is there any kind of syntax
highlighting, ie..if I select a particular character on the right side, it would highlight the
corresponding hex value on the left side or vice versa?
  Or maybe xxd isn't meant for this. Is there some other way to easily view the hex representation
of a file while also showing which hex values correspond to which characters?

Thanks,
Ven

--
--
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
 
---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: XXD with Vim

Tim Chase
On 2014-02-04 10:50, Ven Tadipatri wrote:

>   It's nice that you can go into hex mode with Vim through the use
> of XXD, but it's really hard
> trying to find out what hex codes correspond to a given character.
> Is there any kind of syntax
> highlighting, ie..if I select a particular character on the right
> side, it would highlight the
> corresponding hex value on the left side or vice versa?
>   Or maybe xxd isn't meant for this. Is there some other way to
> easily view the hex representation
> of a file while also showing which hex values correspond to which
> characters?

While I don't believe there's an easy way to dynamically highlight the
character and the corresponding hex code together, you have some
options.  Either you can statically color the columns to make
them easier to spot, something like this ugly one-liner:

:match Error /\(\%10c\|\%11c\|\%15c\|\%16c\|\%20c\|\%21c\|\%25c\|\%26c\|\%30c\|\%31c\|\%35c\|\%36c\|\%40c\|\%41c\|\%45c\|\%46c\|\%51c\|\%53c\|\%55c\|\%57c\|\%59c\|\%61c\|\%63c\|\%65c\)./

(it just picks out the column-numbers that should be highlighted, so
this is lazily hard-coded to 16-column xxd output format).

Or you can instruct xxd to show fewer columns to make it harder to
get lost.  By default, it shows 16 columns, but sometimes 4 or 8 is
easier to work with:

  xxd -c 4 file.bin > file.txt
  vim file.txt
  xxd -r -c 4 < file.txt > file_edited.bin

-tim




--
--
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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
Bee
Reply | Threaded
Open this post in threaded view
|

Re: XXD with Vim

Bee
In reply to this post by Ven Tadipatri
On Tuesday, February 4, 2014 7:50:58 AM UTC-8, vtadipatri wrote:
> It's nice that you can go into hex mode with Vim through the use of XXD, but it's really hard trying to find out what hex codes correspond to a given character. Is there any kind of syntax highlighting, ie..if I select a particular character on the right side, it would highlight the corresponding hex value on the left side or vice versa?
> Or maybe xxd isn't meant for this. Is there some other way to easily view the hex representation of a file while also showing which hex values correspond to which characters?

Not exactly the way you are looking for,
but it does exactly what you want:

http://bvi.sourceforge.net/

The bvi is a display-oriented editor for binary files (hex editor), based on the vi texteditor. If you are familiar with vi, just start the editor and begin to edit! A bmore program is also included in the package.

--
--
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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: XXD with Vim

Lech Lorens
In reply to this post by Ven Tadipatri
On Tuesday, February 4, 2014 4:50:58 PM UTC+1, vtadipatri wrote:
> Hi,
>   It's nice that you can go into hex mode with Vim through the use of XXD, but it's really hard
> trying to find out what hex codes correspond to a given character. Is there any kind of syntax
> highlighting, ie..if I select a particular character on the right side, it would highlight the
> corresponding hex value on the left side or vice versa?

I've written such a plugin a long time ago.  I just submitted it for inclusion in Vim.

Meanwhile, find the plugin attached.

Enjoy,
Lech

--
--
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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.

xxd.vim (2K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

RE: XXD with Vim

JohnBeckett
In reply to this post by Ven Tadipatri
Ven Tadipatri wrote:
> It's nice that you can go into hex mode with Vim through the
> use of XXD, but it's really hard trying to find out what hex
> codes correspond to a given character.

You know about ga and g8? In normal mode, put the cursor on a
character of interest then type ga or type g8 (:help ga).
g8 is good for UTF-8 as it shows the bytes used.

John


--
--
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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: XXD with Vim

Dominique Pellé
John Beckett <[hidden email]> wrote:

> Ven Tadipatri wrote:
>> It's nice that you can go into hex mode with Vim through the
>> use of XXD, but it's really hard trying to find out what hex
>> codes correspond to a given character.
>
> You know about ga and g8? In normal mode, put the cursor on a
> character of interest then type ga or type g8 (:help ga).
> g8 is good for UTF-8 as it shows the bytes used.
>
> John

Hi

In my ~/.vimrc, I have configured the statusline to
show the Unicode character (something like U+00E9
for é) of the character under the cursor, as well as its
UTF-8 sequence (something like 0xc3 0xa9 for é).

It looks like this (cursor on the é):

http://dominique.pelle.free.fr/pic/statusline.png

See statusline and function ShowUtf8Sequence() there:

http://dominique.pelle.free.fr/.vimrc.xhtml

Regards
Dominique

--
--
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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: XXD with Vim

Reid Thompson
On Wed, 2014-02-05 at 07:44 +0100, Dominique Pellé wrote:

> John Beckett <[hidden email]> wrote:
> 
> > Ven Tadipatri wrote:
> >> It's nice that you can go into hex mode with Vim through the
> >> use of XXD, but it's really hard trying to find out what hex
> >> codes correspond to a given character.
> >
> > You know about ga and g8? In normal mode, put the cursor on a
> > character of interest then type ga or type g8 (:help ga).
> > g8 is good for UTF-8 as it shows the bytes used.
> >
> > John
> 
> Hi
> 
> In my ~/.vimrc, I have configured the statusline to
> show the Unicode character (something like U+00E9
> for é) of the character under the cursor, as well as its
> UTF-8 sequence (something like 0xc3 0xa9 for é).
> 
> It looks like this (cursor on the é):
> 
> http://dominique.pelle.free.fr/pic/statusline.png
> 
> See statusline and function ShowUtf8Sequence() there:
> 
> http://dominique.pelle.free.fr/.vimrc.xhtml
> 
> Regards
> Dominique
> 
> -- 

i use this in my status line.
   dec/hex\ \%03.3b/\%02.2B\ 

shows decimal and hex values for char under cursor ala with cursoron an
equals sign char
   dec/hex 061/3D


--
--
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
 
---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.