A custom editor extension for Visual Studio Code which provides a hex editor for viewing and manipulating files in their raw hexadecimal representation.
- Opening files as hex
- A data inspector for viewing the hex values as various different data types
- Editing with undo, redo, copy, and paste support
- Copying bytes in other formats with "Copy As...", such as C arrays, Base64, or a hex dump like
hexdump -Cprints - Find and replace
There are several ways to open a file in the hex editor:
- Right click a file in the Explorer -> Open in Hex Editor
- Right click a file -> Open With... -> Hex Editor
- Trigger the command palette (F1) -> Hex Editor: Open Active File in Hex Editor
- Trigger the command palette (F1) -> Reopen Editor With... -> Hex Editor
To go back to the text editor, use the "Reopen with Text Editor" button in the title of the hex editor, or run "Hex Editor: Reopen with Text Editor" from the command palette.
An "Open Active File in Hex Editor" button can also be added to the title of other editors. Enable hexeditor.showOpenFileButton to show it for every file, or list the extensions of the files to show it for, including their leading dot:
"hexeditor.showOpenFileButtonForExtensions": {
".png": true,
".ico": true
},The hex editor can be set as the default editor for certain file types by using the workbench.editorAssociations setting. For example, this would associate all files with extensions .hex and .ini to use the hex editor by default:
"workbench.editorAssociations": {
"*.hex": "hexEditor.hexedit",
"*.ini": "hexEditor.hexedit"
},By default, typing in the hex editor inserts new bytes before the focused byte. To overwrite bytes instead, press Insert, click the edit mode in the status bar, or run "Hex Editor: Switch Edit Mode". The mode new editors open in can be changed with the hexeditor.defaultEditMode setting.
To make patterns in the data easier to spot, the hexeditor.byteColors setting colors bytes by their value, in both the hex and the decoded text. It can dim zero bytes (dimZeros), color bytes by category (categories: printable ASCII, other ASCII, and non-ASCII), or give bytes a color for each first hex digit (rainbow). The colors follow the color theme.
The decoded text shows printable ASCII characters, and dots for other bytes. To show text in another encoding, set hexeditor.decodedTextEncoding, for example to utf-8, utf-16le, windows-1252, shift_jis or the EBCDIC code page ibm037. Characters of several bytes are shown across the bytes that encode them, and bytes that aren't valid in the encoding as �. Typing into the decoded text enters the characters in its encoding.
To tell control characters apart, set hexeditor.renderControlCharacters to show them, and spaces, as symbols such as ␀, ␉, ␊ and ␣.
These can also be changed from the settings gear in the top left of the editor.
To show bytes in groups of 2, 4, 8, or 16, like 0A1B 2C3D, choose "Bytes per group" in the editor's settings (the gear at its top left) or change the hexeditor.bytesPerGroup setting. Groups start at the beginning of each row, so if the bytes per row aren't a multiple of the group size, the last group of each row is shorter.
The data inspector decodes the bytes starting at the focused byte. When two or more adjacent bytes are selected, it decodes the selection instead, from its first byte, and only shows the types that fit within it, such as uint16 for two bytes or float64 for eight.
By default, the data inspector is shown just to the right of the data grid (or decoded text if enabled), but it can be configured (via the hexeditor.inspectorType setting) to instead show up while hovering over a data cell.
Another option is to give the data inspector a dedicated activity bar entry on the left (by setting hexeditor.inspectorType to sidebar) that appears when the hex editor is opened, causing the explorer or whatever sidebar you had opened to be hidden. If preferred, the hex editor view can be dragged into another view by dragging the ⬡ icon onto one of the other views. This can be used in combination with the hexeditor.dataInspector.autoReveal setting to avoid revealing the sidebar containing the data inspector altogether.
The hex editor can be used with only the keyboard and with screen readers.
| Key | Action |
|---|---|
| Tab / Shift+Tab | Move focus into the bytes, to the same byte in the decoded text, and out again. Focus comes back to the byte it left. |
| Arrow keys | Move between bytes. Hold Alt to move 8 times as far. |
| Home / End | Go to the start or end of the file. On macOS, Cmd+Up / Cmd+Down do too, and Cmd+Left / Cmd+Right go to the start or end of the row. |
| Page Up / Page Down | Move a page up or down. |
| Shift + any of the above | Select bytes. Ctrl/Cmd+A selects all of them. |
0-9, A-F |
Edit the focused byte in the hex column, two digits per byte. In the decoded text, type characters instead. |
| Insert | Switch between inserting and replacing bytes. |
| Delete | Delete the selected bytes. |
| Ctrl+G | Go to an offset. |
| Ctrl/Cmd+F | Find. Enter and Shift+Enter go to the next and previous match, and Alt+Enter selects all of them. Escape closes the find widget and focuses the match you went to. |
The settings button is before the bytes in the tab order. It and the popup that asks how to paste text close with Escape, which puts focus back where it was.
Screen readers read the bytes as a grid, with the row and column of each byte in the whole file, even though only the rows on screen are rendered. Each byte is read with its value and offset, such as "4A, offset 0x1F". In the decoded text, control characters are read by their ASCII names, such as "NUL" or "LF". Screen readers also announce:
- the edit mode, when focus moves into the bytes and when it's switched,
- each byte you type, delete, cut, or paste, and undo and redo, and the first digit of a byte while it waits for the second,
- how many bytes are selected when you select with the keyboard,
- how many matches a search found, and which match you went to,
- when a file can't be edited because it's read-only.
These announcements are turned off when VS Code's editor.accessibilitySupport setting is off.
The data inspector that's shown beside the bytes is a region named "Data Inspector" before them. The inspector that shows while hovering over bytes can only be opened with the mouse, so with the keyboard or a screen reader, set hexeditor.inspectorType to aside or sidebar. The sidebar inspector is a view that can be focused with the "Focus on Data Inspector View" command.
To track existing issues or report a new one, please visit the GitHub Issues page at https://github.com/microsoft/vscode-hexeditor/issues
