Linux Vim has an error in hexadecimal format. When viewing and editing a binary file, you must add the-B parameter.
Today, you need to check the hexadecimal file. When debugging, you find that something is wrong. After comparison, we find that Vim needs to add the-B parameter when opening the binary file.
Vim test. Bin
: %! Xxd // display hexadecimal
0000000: 0300 0800 3c0d 0000 0100 1c00 3f05 0000 ....<.......?...0000010: 2700 0000 0000 0000 0000 0000 3f00 0000 '...........?...0000020: 0000 0000 0000 0000 1a00 0000 3400 0000 ............4...0000030: 4000 0000 4e00 0000 5a00 0000 6800 0000 @...N...Z...h...0000040: 3f00 0000 3f00 0000 3f00 0000 3f00 0000 ?...?...?...?...0000050: 0601 0000 1a01 0000 2e01 0000 5601 0000 ............V...0000060: 7001 0000 3f01 0000 3f01 0000 3f01 0000 p...?...?...?...0000070: 3f01 0000 0002 0000 1402 0000 5802 0000 ?...........X...0000080: 3f02 0000 3f02 0000 3f02 0000 3f02 0000 ?...?...?...?...0000090: 1603 0000 3803 0000 5a03 0000 7803 0000 ....8...Z...x...00000a0: 3f03 0000 3f03 0000 3f03 0000 3f03 0000 ?...?...?...?...00000b0: 1404 0000 3604 0000 7004 0000 3f04 0000 ....6...p...?...
Vim-B test. Bin
: %! Xxd // display hexadecimal
0000000: 0300 0800 3c0d 0000 0100 1c00 8805 0000 ....<...........0000010: 2700 0000 0000 0000 0000 0000 b800 0000 '...............0000020: 0000 0000 0000 0000 1a00 0000 3400 0000 ............4...0000030: 4000 0000 4e00 0000 5a00 0000 6800 0000 @...N...Z...h...0000040: 8600 0000 9800 0000 f000 0000 f400 0000 ................0000050: 0601 0000 1a01 0000 2e01 0000 5601 0000 ............V...0000060: 7001 0000 8401 0000 9a01 0000 b801 0000 p...............0000070: c801 0000 0002 0000 1402 0000 5802 0000 ............X...0000080: 8402 0000 b402 0000 d202 0000 f402 0000 ................0000090: 1603 0000 3803 0000 5a03 0000 7803 0000 ....8...Z...x...00000a0: 8c03 0000 a203 0000 e603 0000 fe03 0000 ................00000b0: 1404 0000 3604 0000 7004 0000 ba04 0000 ....6...p.......
According to short, data exceeding 7ffff will show errors
If you need to edit the file, only the modification of the hexadecimal part will be used. The modification of the text area displayed on the right is negligible.
========================================================== ======================================
After editing, we need to restore it to a binary file:
: %! Xxd-R # parameter-R refers to converting the current hexadecimal format to binary
OK. Save and exit:
: WQ
A real binary editor displays text in two ways: Binary and hexadecimal formats. You can
To achieve this effect through the conversion program "xxd. This program is released along with vim.
First, edit the file in binary mode: