HexViewerPlus
HexViewerPlus —— 一款 Visual Studio Code 自定义编辑器扩展,提供十六进制查看/编辑功能,可以以原始十六进制表示查看和操作文件,并支持高级格式(SREC、IntelHex、TI-TXT、ELF)。
本软件由 公众号:嵌入式软件实战派 设计。
HexViewerPlus - a custom editor extension for Visual Studio Code that provides a hex viewer/editor for viewing and manipulating files in their raw hexadecimal representation, with advanced format support (SREC, IntelHex, TI-TXT, ELF).
This software is designed by 公众号:嵌入式软件实战派.
功能特性 / Features
功能一览 / Function Overview
| 功能 Feature |
基础版 Basic |
高级版 Pro |
| 两种自定义编辑器 / Two Custom Editors |
✔ |
✔ |
| 支持的格式(自动检测) / Supported Formats (Auto-Detected) |
✔ |
✔ |
| Hex格式文件浏览 / Hex Format View |
✔ |
✔ |
| Hex格式文件信息页 / Hex Format View of File-Info |
✔ |
✔ |
| ELF文件信息页 / ELF analyse Info |
✔ |
✔ |
| 复制为 — 9 种输出格式 / Copy As — 9 Output Formats |
✔ 全功能 full function |
✔ 全功能 full function |
| 高级导航 / Advanced Navigation |
✔ |
✔ |
| 数据检查器 / Data Inspector |
✔ |
✔ |
| 搜索 / Search |
✔ |
✔ |
| 大小端、ASCII文本、GAP折叠 / LE/BE, ASCII text, Compact GAP |
✔ 全功能 full function |
✔ 全功能 full function |
| 编辑功能 / Edit Features (binary) |
✔ |
✔ |
| 文件比较 / File Comparison |
1MB file size limited |
No size limited |
| 导出报告 / Export as Report |
⛔ 需 Pro 授权 Pro required |
✔ |
两种自定义编辑器 / Two Custom Editors
| 编辑器 / Editor |
类型 / Type |
适用场景 / Use Case |
hexViewerPlus.hexEdit |
读写 Read & Write |
功能完整的编辑器,支持撤销/重做、保存、备份、磁盘变更检测 Full-featured editor with undo/redo, save, backup, and disk-change detection |
hexViewerPlus.hexFormatViewer |
只读 Read Only |
轻量级 HTML 视图,用于快速浏览和文件比较 Lightweight HTML view for quick browsing and file comparison |
| 格式 / Format |
扩展名 / Extensions |
说明 / Description |
| S-Record (SREC) |
.srec, .s19 |
Motorola S-record,类型 0–9,带 CRC 校验 Types 0–9 with CRC validation |
| Intel HEX |
.hex, .ihex |
支持扩展线性/段地址,最高 48 位地址 Extended Linear/Segment Address support, up to 48-bit addresses |
| TI-TXT |
.txt |
德州仪器格式(@ 地址行,q 终止符) Texas Instruments format (@ address lines, q terminator) |
| ELF |
.elf, .out |
精简解析器:32/64 位,小端/大端,PT_LOAD 段 + 入口点 Minimal parser: 32/64-bit, Little/Big endian, PT_LOAD segments + entry point |
| Binary |
.bin |
从偏移 0 开始的原始二进制 Raw binary from offset 0 |
选中字节 → 右键(或 Alt+Ctrl+C)→ 选择格式:
Select bytes → right-click (or Alt+Ctrl+C) → choose format:
| 格式 / Format |
输出示例 / Example Output |
用途 / Use Case |
| Hex Octets |
00 01 02 FF |
通用十六进制显示 General hex display |
| Hex |
000102FF |
紧凑无分隔符 Compact no-separator |
| Literal |
\x00\x01\x02\xff |
C/Go/Python 字符串字面量 C/Go/Python string literal |
| UTF-8 |
Hello World |
原始文本内容 Raw text content |
| C |
unsigned char name[4] = { 0x00, 0x01, 0x02, 0xFF }; |
C/C++ 数组初始化 C/C++ array init |
| Go |
var name = []byte{0x00, 0x01, 0x02, 0xFF} |
Go 字节切片 Go byte slice |
| Java |
byte name[] = { 0x00, 0x01, 0x02, 0xFF }; |
Java 字节数组 Java byte array |
| JSON |
[0, 1, 2, 255] |
JSON 数字数组 JSON number array |
| Base64 |
AAECAf8= |
Base64 编码 Base64 encoding |
文件比较与报告 / File Comparison & Report
- 比较任意两个文件(甚至混合格式,例如
.hex 与 .elf)
Compare any two files (even mixed formats, e.g. .hex vs .elf)
- 逐字节差异比较,差异部分红色高亮
Byte-by-byte diff with red-highlighted differences
- 智能折叠:相同区域 ≥256 字节、间隔 ≥64 字节自动折叠
Smart collapse: identical regions ≥256 bytes, gaps ≥64 bytes auto-folded
- 导出完整的 HTML 报告,包含摘要统计和逐行表格
Export comprehensive HTML report with summary stats and row-by-row table
高级导航 / Advanced Navigation
| 操作 / Action |
快捷键 / Shortcut |
跳转到偏移量 Jump to offset |
Ctrl+G |
在偏移量之间选择 Select between offsets |
命令面板 / Command Palette |
复制偏移量为十六进制/十进制 Copy offset as hex / dec |
右键上下文菜单 / Right-click context menu |
切换编辑模式(只读/读写) Switch edit mode (read/write) |
Insert |
数据检查器 / Data Inspector
实时解码选中字节的值,支持:
Real-time decoded value of selected bytes, supporting:
- 整数类型:Int8 / Int16 / Int32 / Int64 / Uint8 / Uint16 / Uint32 / Uint64
Integer types: Int8 / Int16 / Int32 / Int64 / Uint8 / Uint16 / Uint32 / Uint64
- 浮点类型:Float / Double
Floating point: Float / Double
- 可配置字节序(小端 / 大端)
Configurable endianness (Little / Big)
- 三种显示模式:Aside(网格旁边)、Hover(鼠标悬停)、Sidebar(专用面板)
Three display modes: Aside (next to grid), Hover (on mouseover), Sidebar (dedicated panel)
搜索 / Search
- 字面量搜索:查找字节序列(支持通配符
* 匹配任意字节)
Literal search: Find byte sequences (supports wildcard * for any byte)
- 正则搜索:对 ASCII 解释进行正则表达式匹配
Regex search: Regular expression matching on ASCII interpretation
- 流式结果,带实时进度反馈
Streaming results with real-time progress feedback
- 区分大小写选项
Case-sensitive option
编辑功能 / Edit Features
- 直接在网格中编辑字节值
Direct byte value editing in the grid
- 完整的撤销/重做历史
Full undo / redo history
- 自动备份(兼容 VSCode 热退出)
Automatic backup (VSCode Hot Exit compatible)
- 磁盘变更检测 —— 当外部程序修改文件时提示
Disk change detection — prompts when external programs modify the file
命令 / Commands
| 命令 / Command |
快捷键 / Shortcut |
说明 / Description |
HexViewerPlus: Open File in HexEditor |
— |
以十六进制编辑器打开文件(图标按钮) Open file as hex editor (icon button) |
HexViewerPlus: Go to Offset |
Ctrl+G |
跳转到指定地址 Jump to specified address |
HexViewerPlus: Select Between Offsets |
— |
选择两个地址之间的字节 Select bytes between two addresses |
HexViewerPlus: Copy As... |
Alt+Ctrl+C |
以所选格式复制选中的字节 Copy selected bytes in chosen format |
HexViewerPlus: Switch Edit Mode |
Insert |
切换只读 / 读写 Toggle read-only / read-write |
HexViewerPlus: Copy Offset as Hex |
— |
复制当前光标地址(十六进制) Copy current cursor address (hex) |
HexViewerPlus: Copy Offset as Dec |
— |
复制当前光标地址(十进制) Copy current cursor address (decimal) |
HexViewerPlus: Open File in HexFormatView |
— |
在只读视图中打开(在资源管理器中右键) Open in read-only view (right-click in Explorer) |
HexViewerPlus: Compare Selected in HexFormatView |
— |
比较两个文件(在 HexFormatView 中双击选择两个) Compare two files (double-select in HexFormatView) |
HexViewerPlus: Export Compare Report (HTML) |
— |
将比较结果导出为 HTML 文件 Export comparison result as HTML file |
HexViewerPlus: Enter License Key |
— |
使用许可证密钥激活 Activate with license key |
HexViewerPlus: Get Activation Code |
— |
生成并复制机器 ID + 激活码 Generate and copy Machine ID + activation code |
配置 / Configuration
| 设置项 / Setting |
类型 / Type |
默认值 / Default |
说明 / Description |
hexViewerPlus.inspectorType |
aside / hover / sidebar |
aside |
数据检查器的显示位置 Where to show the Data Inspector |
hexViewerPlus.maxFileSize |
number |
10 |
大文件阈值(MB) Large file size threshold (MB) |
hexViewerPlus.dataInspector.autoReveal |
boolean |
true |
自动显示数据检查器侧边栏 Auto-reveal Data Inspector sidebar |
hexViewerPlus.defaultEndianness |
little / big |
little |
解码值的默认字节序 Default byte order for decoded values |
hexViewerPlus.columnWidth |
integer (1–512) |
16 |
列宽设置 Column width setting |
hexViewerPlus.bytesPerRow |
integer (1–512) |
16 |
每行显示的字节数 Bytes displayed per row |
hexViewerPlus.showAscii |
boolean |
true |
显示 ASCII 解码列 Show ASCII decode column |
hexViewerPlus.copyType |
string (见上文) |
Hex Octets |
默认“复制为”格式 Default Copy As format |
hexViewerPlus.showDecodedText |
boolean |
true |
显示解码文本列 Show decoded text column |
hexViewerPlus.showOpenFileButton |
boolean |
false |
在编辑器标题栏显示打开文件按钮 Show open-file button in editor title bar |
使用方法 / How to Use
有几种方式可以用 HexViewerPlus 打开文件:
There are several ways to open files with HexViewerPlus:
方法 1:从资源管理器(推荐) / Method 1: From Explorer (Recommended)
- 在 VSCode 资源管理器中右键任意文件
Right-click any file in the VSCode Explorer
- 选择 "Open File in HexFormatView"(只读)或 "Open File in HexEditor"(读写)
Choose "Open File in HexFormatView" (read-only) or "Open File in HexEditor" (read-write)
方法 2:命令面板 / Method 2: Command Palette
- 按 F1 或 Ctrl+Shift+P
Press F1 or Ctrl+Shift+P
- 运行 "HexViewerPlus: Open File in HexEditor" 或 "HexViewerPlus: Open File in HexFormatView"
Run "HexViewerPlus: Open File in HexEditor" or "HexViewerPlus: Open File in HexFormatView"
方法 3:重新打开方式 / Method 3: Reopen With
- 先用其他扩展打开一个文件
Open a file with any other extension first
- 按 F1 → "Reopen With..." → 选择 HexViewerPlus
Press F1 → "Reopen With..." → select HexViewerPlus
设为默认编辑器 / Set as Default Editor
通过 workbench.editorAssociations 将特定文件扩展名关联到 HexViewerPlus:
Associate specific file extensions with HexViewerPlus via workbench.editorAssociations:
"workbench.editorAssociations": {
"*.hex": "hexViewerPlus.hexEdit",
"*.s19": "hexViewerPlus.hexEdit",
"*.bin": "hexViewerPlus.hexEdit",
"*.elf": "hexViewerPlus.hexEdit"
}
比较两个文件 / Comparing Two Files
- 在 HexFormatView 中,双击资源管理器中的两个文件以同时选中它们
In HexFormatView, double-click two files in the Explorer to select them both
- 右键 → "Compare Selected in HexFormatView"
Right-click → "Compare Selected in HexFormatView"
- 查看并排差异,然后 "Export Compare Report (HTML)" 导出可分享的报告
Review the side-by-side diff, then "Export Compare Report (HTML)" for a shareable report
许可证激活 / License Activation
HexViewerPlus 使用机器绑定的许可证密钥来访问大文件(>1 MB)。
HexViewerPlus uses machine-bound license keys for large file access (>1 MB).
激活流程 / Activation Flow
- 运行命令 "Get Activation Code" —— 你的唯一机器 ID 和激活码会被复制到剪贴板
Run command "Get Activation Code" — your unique Machine ID and activation code are copied to clipboard
- 将激活码发送给许可证提供者(获取许可证)
Send the activation code to your license provider(GET LICENSE)
- 收到返回的 HexVP-XXXXXXXX 许可证密钥
Receive back an HexVP-XXXXXXXX license key
- 运行 "Enter License Key" → 粘贴密钥 → 验证
Run "Enter License Key" → paste the key → validate
许可证本地存储在 ~/.hexviewerplus/license.json,后续启动时自动加载。许可证绑定到你的机器指纹(Windows:MachineGuid,macOS:IOPlatformUUID,Linux:/etc/machine-id)。
The license is stored locally at ~/.hexviewerplus/license.json and automatically loaded on subsequent startups. The license is bound to your machine fingerprint (Windows: MachineGuid, macOS: IOPlatformUUID, Linux: /etc/machine-id).
HexViewerPlus 专为超大固件文件设计。关键优化:
HexViewerPlus is engineered for extremely large firmware files. Key optimizations:
- O(n) 段合并(对比 O(n²) 增量):152K 个段合并为 2 个,约 72ms(原来约 118s)
O(n) segment merging (vs. O(n²) incremental): 152K segments merged to 2 in ~72ms (was ~118s)
- 段驱动虚拟滚动:仅遍历数据段,跳过 90% 以上的间隙区域
Segment-driven virtual scroll: iterates only over data segments, skipping 90%+ gap areas
- 批量 base64 编码:单次分配 + 编码,取代 152K 次小块编码
Batch base64 encoding: single allocation + encode instead of 152K small chunk encodes
- byteAt 二分查找:O(log n) 查找,对比 O(n) 线性扫描
Binary search for byteAt: O(log n) lookup vs. O(n) linear scan
基准测试:Appl.hex —— 152,652 行,4.8 MB 源文件,11.2 MB 地址跨度,约 43% 数据密度。
Benchmark: Appl.hex — 152,652 lines, 4.8 MB source, 11.2 MB address span, ~43% data density.
已知问题 / Known Issues
要跟踪现有问题或报告新问题,请访问问题跟踪器。
To track existing issues or report a new one, please visit the issue tracker.
第三方许可证 / Third-Party Licenses
本扩展包含源自以下开源项目的代码:
This extension includes code derived from the following open-source project:
vscode-hexeditor
- 来源:https://github.com/microsoft/vscode-hexeditor
Source: https://github.com/microsoft/vscode-hexeditor
- 版权:Copyright (c) Microsoft Corporation. All rights reserved.
Copyright: Copyright (c) Microsoft Corporation. All rights reserved.
- 许可证:MIT License
License: MIT License
完整的版权声明和许可证文本如下所示。
The full copyright notice and license text are reproduced below.
MIT License
Copyright (c) Microsoft Corporation. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
本扩展本身是专有软件。其许可条款可在扩展包中包含的 LICENSE.md 文件中查看。
This extension itself is proprietary software. Its license terms are
available in the LICENSE.md file included in the extension package.