TIL - xxd color support

Posted by Marcus Folkesson on Tuesday, January 2, 2024

TIL - xxd color support

TIL, Today I Learned, is more of a "I just figured this out: here are my notes, you may find them useful too" rather than a full blog post

Today (2 January 2024), version 9.1 of the Vim editor has been released [1]!

xxd [2] is a utility that is distributed with Vim and is my go-to-tool when it comes to view or manipulating binary files.

A feature I've been missing for a long time is finally here - color support!

To enable colors, use the -R flag (same as for less and hexdump). E.g.:

1$xxd -R always $FILE | less -R
/media/xxd.png

The hex-value and value are both colored with the same color depending on the hex-value:

  • 0x00 = white
  • 0xff = blue
  • printable = green
  • non-printable = red
  • tabs and linebreaks = yellow