KP Solutions

Solutions for Day to Day Technical Problems

How to edit HEX file in VI?

| 1 Comment

Open the hex file or any file that you want to edit in hex format in “vi“. Lets call that file “myFile.hex”.

To open the file in “vi“, type in terminal “vi myFile.hex

After the file is opened in the “vi“, make sure you are in the command mode. If you are not sure, just hit “ESC” couple of times and it should then be in command mode.

Now type the following “:%!xxd“.

Voila, you are editing the file in hex mode now! Isn’t this awesome?

If you want to revert back to regular editing mode instead of hex mode, then make sure you are in command mode & then type the following “:%!xxd -r“.

This will bring you back to normal editing mode. Isn’t this easy?

Let me know if you have some tricks saved in your sleeves, we can share it here with others.