Logan Rathbone
poprocks@gmail.com 2022
Enrico Nicoletto
liverig@gmail.com 2013.

# Editing files

# Toggling the hex or ASCII panes

File can be edited in GHex from either the hex pane or the ASCII pane.

To focus either pane to accept your keystrokes, you may click on the appropriate pane, or:

Press Alt Left to focus the hex pane, and

Press Alt Right to focus the ASCII pane.

# Editing the file using the hex or ASCII pane

Edit the ASCII format in the same way you edit a normal text file.

To edit the hexadecimal format, use the values 0 to 9 and a to f. This operation is not case-sensitive.

Use any of the following methods to move the cursor around the file:

Use the scrollbar on the window and the mouse to select a byte by clicking on it.

Use the arrow keys, Home, End, PageUp or PageDown on the keyboard.

Choose Jump to Byte from the (Main menu) or press Ctrl J, and enter the cursor offset as a decimal or hexadecimal value. The format of the hexadecimal value must be 0x followed by the offset, for example 0x3.

To delete or zero-out data, use either the Delete or Backspace keys. Cut operations will also have the side-effect of removing or zeroing-out data. This behaviour is different depending on whether or not Insert Mode is enabled. For more information, please review the section below.

# Insert mode

Insert Mode can be toggled on or off by pressing Insert, or by clicking the Toggle insert mode button in the status bar.

When Insert Mode is enabled, this means data will be added to the file as opposed to replacing existing data.

Unlike traditional text editors, having Insert Mode off is considered the default state in GHex, given that hex editors are routinely used to edit existing data in binary files that are very specifically laid out. In some cases, such files may be of a fixed size and increasing or decreasing their size may cause undefined or unwanted behaviour in applications that open them.

Along these lines, delete operations work differently depending upon whether or not Insert Mode is enabled.

If Insert Mode is enabled, delete operations (eg, by pressing Delete, Backspace, or by a cut operation) will alter the file length, by removing the data from the file.

If Insert Mode is not enabled, delete operations will instead zero-out affected bytes within the file, so as to avoid changing the length of the file.

# Setting geometry

By default, GHex fits as many characters as the width of the window can reasonably allow. However, GHex also allows you to specify how many characters will be displayed per line. This can be useful when working with data that is grouped into chunks (eg, 16 bytes at a time) or simply as a way of visually keeping track of offsets on a line-by-line basis.

In GHex, this is called setting geometry. Geometry can be customized by right-clicking anywhere in the hex or ASCII panes, and clicking Geometry, unchecking Automatic geometry and then specifying the desired number of characters per line. GHex will then automatically reformat the hex and ASCII panes accordingly. This only takes effect for the file being worked on, and does not persist across sessions.