vim十六进制格式查看

xxd

xxd是linux下一个显示、编辑、转换二进制命令

man xxd 查看帮助
DESCRIPTION
    xxd  creates  a  hex  dump of a given file or standard input.  It can also
    convert a hex dump back to its original binary form.  Like uuencode(1) and
    uudecode(1)  it  allows  the  transmission of binary data in a `mail-safe'
    ASCII representation, but has the advantage of decoding to  standard  out-
    put.  Moreover, it can be used to perform binary file patching.

:%!xxd

解释:把所有的行(%)用本地(!)的xxd程序打开。
在vim中使用xxd可以把文件转换为16进制来显示

:%!xxd -r

返回正常显示

vim -b binaryfile

以二进制方式编辑文件
vim的-b选项表示打开一个二进制文件,不指定会在后面加上一个换行符0x0a
然后用 :%!xxd 把其文件转换成十六进制

Vim 把这些信息当作普通文本来对待,可以随意编辑。
修改了十六进制部分并不导致可打印字符部分的改变,反之亦然。
只有十六进制部分的修改才会被采用。右边可打印文本部分的修改忽略不计

:%!xxd -g 1 表示每1个字节为1组
:%!xxd -g 2 表示每2个字节为1组(默认)
:%!xxd -g 4 表示每4个字节为1组