Skip to content

sanohiro/ehx

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ehx — Emacs Hex Editor

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.

日本語


Why ehx?

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.


Key Characteristics

  • 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-F as hex digits. Japanese IME friendly.


Install

Homebrew (macOS / Linux)

brew tap sanohiro/ehx
brew install ehx

apt (Debian / Ubuntu)

curl -fsSL https://sanohiro.github.io/ehx/install.sh | sudo sh
sudo apt install ehx

Or download .deb directly from Releases:

wget https://github.com/sanohiro/ehx/releases/latest/download/ehx_amd64.deb
sudo apt install ./ehx_amd64.deb

Build from source

# 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/

Quick Start

ehx file.bin          # Open a file
ehx                   # Start with empty buffer
cat file.bin | ehx    # Read from stdin
echo -n "Hello" | ehx # Pipe data

Save and quit: C-x C-sC-x C-c


Keybindings

ehx uses Emacs-style keybindings. C- means Ctrl, M- means Alt/Option.

Cursor Movement

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

Editing

Key Action
C-d / Backspace Delete byte
Tab Toggle HEX / ASCII input
Insert Toggle Overwrite / Insert mode
C-u / C-/ Undo / Redo

Selection & Clipboard

Key Action
C-SPC Start selection
M-w / C-w / C-y Copy / Cut / Paste
C-g Cancel

Search & Replace

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 text
  • 48 65 6C 6C 6F — Spaced HEX
  • 48656C6C6F — Continuous HEX

File Operations

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)

Navigation

Key Action
M-g Goto address (hex: 0x100, 100h, or decimal)

Commands (M-x)

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

Display

Key Action
F2 Cycle encoding

Input Modes

HEX Mode (default)

Type hex digits (0-9, A-F) to edit bytes directly. Full-width characters (0-9, A-F) are automatically converted.

ASCII Mode

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)

Paste Formats

Bracketed paste auto-detects format:

  • 48 65 6C 6C 6F — Spaced HEX
  • 48656C6C6F — Continuous HEX
  • Hello — Raw text (as bytes)

Clipboard Integration

  • Uses OSC 52 escape sequence to copy to system clipboard
  • Works over SSH with iTerm2, kitty, alacritty, WezTerm
  • tmux: Add set -g allow-passthrough on to your .tmux.conf

Inspiration

  • ze — Zero-latency Emacs-like editor
  • hexyl — Hex viewer
  • Stirling — GUI hex editor

bx — Binary Tool for Pipes

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   # Hello

License

MIT


"Edit binary like you edit text."

About

Hex editor with Emacs keybindings

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages