A terminal hex editor for those who think in C-x C-s.
This package includes two tools:
- ehx — Interactive TUI hex editor
- bx — CLI binary tool for pipes
If xxd feels primitive and GUI hex editors feel heavy, ehx is the middle ground.
Most hex editors use vi-style or custom keybindings. ehx is for Emacs users who don't want to context-switch their muscle memory just to edit a binary file.
- Same navigation:
C-f,C-b,C-n,C-p - Same file operations:
C-x C-s,C-x C-c - Same selection:
C-SPC,M-w,C-w,C-y - Same search:
C-s,C-r
No relearning. No mode switching confusion. Just edit bytes like you edit text.
-
Emacs keybindings Familiar cursor movement and editing commands.
-
Dual-pane view HEX and ASCII side by side. Tab to switch input focus.
-
Multi-encoding support UTF-8, UTF-16, Shift-JIS, EUC-JP, and more.
-
Clipboard integration System clipboard + OSC 52 (works over SSH).
-
Full-width character support Input
0-9,A-Fas hex digits. Japanese IME friendly.
brew tap sanohiro/ehx
brew install ehxcurl -fsSL https://sanohiro.github.io/ehx/install.sh | sudo sh
sudo apt install ehxOr download .deb directly from Releases:
wget https://github.com/sanohiro/ehx/releases/latest/download/ehx_amd64.deb
sudo apt install ./ehx_amd64.deb# Requires Rust 1.85+
git clone https://github.com/sanohiro/ehx
cd hx
cargo build --release
cp ./target/release/ehx ./target/release/bx ~/.local/bin/ehx file.bin # Open a file
ehx # Start with empty buffer
cat file.bin | ehx # Read from stdin
echo -n "Hello" | ehx # Pipe dataSave and quit: C-x C-s → C-x C-c
ehx uses Emacs-style keybindings. C- means Ctrl, M- means Alt/Option.
| Key | Action |
|---|---|
C-f / C-b / C-n / C-p |
Move cursor |
C-a / C-e |
Beginning / end of row |
C-v / M-v |
Page down / up |
M-< / M-> |
Beginning / end of buffer |
| Key | Action |
|---|---|
C-d / Backspace |
Delete byte |
Tab |
Toggle HEX / ASCII input |
Insert |
Toggle Overwrite / Insert mode |
C-u / C-/ |
Undo / Redo |
| Key | Action |
|---|---|
C-SPC |
Start selection |
M-w / C-w / C-y |
Copy / Cut / Paste |
C-g |
Cancel |
| Key | Action |
|---|---|
C-s / C-r |
Search forward / backward |
M-% |
Query replace |
During query replace: y (replace), n (skip), ! (replace all), q (quit)
Search/replace accepts text or HEX patterns:
hello— ASCII text48 65 6C 6C 6F— Spaced HEX48656C6C6F— Continuous HEX
| Key | Action |
|---|---|
C-x C-s |
Save |
C-x C-w |
Save as |
C-x C-f |
Open file |
C-x k |
Close buffer (new empty buffer) |
C-x C-c |
Quit |
Unsaved changes prompt: y (save & continue), n (discard), c (cancel)
| Key | Action |
|---|---|
M-g |
Goto address (hex: 0x100, 100h, or decimal) |
| Command | Action |
|---|---|
fill / f |
Fill selection with byte (e.g., 00, FF) |
insert / i |
Insert N bytes at cursor (e.g., 16 00, 0x10 FF) |
goto / g |
Jump to address |
save / s |
Save file |
quit / q |
Quit |
help / ? |
Show command list |
| Key | Action |
|---|---|
F2 |
Cycle encoding |
Type hex digits (0-9, A-F) to edit bytes directly.
Full-width characters (0-9, A-F) are automatically converted.
Press Tab to switch. Type any character — it will be encoded using the current encoding:
- UTF-8:
あ→E3 81 82(3 bytes) - Shift-JIS:
あ→82 A0(2 bytes)
Bracketed paste auto-detects format:
48 65 6C 6C 6F— Spaced HEX48656C6C6F— Continuous HEXHello— Raw text (as bytes)
- Uses OSC 52 escape sequence to copy to system clipboard
- Works over SSH with iTerm2, kitty, alacritty, WezTerm
- tmux: Add
set -g allow-passthrough onto your.tmux.conf
Unix-style binary manipulation tool included with ehx.
# Find hex pattern
echo -n "Hello" | bx find 6C6C # Find "ll"
bx find DEADBEEF -i firmware.bin
# Extract byte range
bx slice 0x100:0x200 -i file.bin # Extract bytes
bx slice 0:512 -i file.bin -x # Hex dump
# Replace pattern
bx replace FF00 AA55 < in.bin > out.bin
bx replace --all 00 FF < in > out # Replace all
# Patch at offset
bx patch 0x100=DEAD 0x200=BEEF < in > out
# File info (size, entropy)
bx info -i file.bin
# Convert hex <-> binary
echo -n "Hello" | bx conv bin2hex # 48 65 6C 6C 6F
echo "48656C6C6F" | bx conv hex2bin # HelloMIT
"Edit binary like you edit text."