vim as hex editor?

Yes..who would have thought?

Being a vim user, I hoped it would be able to edit hex files. I didn’t know for sure if it can do it or not so I decided to start digging into the manuals. This nice feature of vim has proven to be really important for me lately, now that I’m testing a protocol by modifying valid pcap files.

So, here it goes: first open your pcap file with vim, as you would any other file:

$>vim myfile.pcap

Once inside vim, hit Esc key and type:

:%!xxd

– to go into hex mode

After you’re done modifying stuff, hit Esc again and type:

:%!xxd -r

– to return to default visual mode

Note: if you decide to save the modification while in hex mode, the file will now contain the hex data represented as strings (just like copy/pasting the hexa visual data into a new text file). Remember to return to the default visual mode with :%!xxd -r before saving the file!

Andrei~

Leave a Reply

Your email address will not be published. Required fields are marked *

*

     

HTML tags are not allowed.