<?xml version="1.0" encoding="utf-8"?>
<page xmlns="http://projectmallard.org/1.0/" type="topic" id="basics-edit-file" xml:lang="zh_CN">
 <info>
  <link type="guide" xref="index#basics"/>
  <revision version="0.1" date="2022-01-04" status="incomplete"/>
  <credit type="author copyright">
   <name>Logan Rathbone</name>
   <email>poprocks@gmail.com</email>
   <years>2022</years>
  </credit>
 </info>
 <title>Editing files</title>
 <section>
  <title>Toggling the hex or ASCII panes</title>
  <p>File can be edited in GHex from either the hex pane or the ASCII pane.</p>
  <p>To focus either pane to accept your keystrokes, you may click on the appropriate pane, or:</p>
  <list>
   <item>
    <p>Press <keyseq><key>Alt</key><key>Left</key></keyseq> to focus the hex pane, and</p>
   </item>
   <item>
    <p>Press <keyseq><key>Alt</key><key>Right</key></keyseq> to focus the ASCII pane.</p>
   </item>
  </list>
 </section>
 <section>
  <title>Editing the file using the hex or ASCII pane</title>
  <p>Edit the ASCII format in the same way you edit a normal text file.</p>
  <p>To edit the hexadecimal format, use the values 0 to 9 and a to f. This
  operation is not case-sensitive.</p>
  <p>使用以下任意方法可以在文件中移动光标：</p>
  <list>
   <item>
    <p>Use the scrollbar on the window and the mouse to select a byte by clicking on it.</p>
   </item>
   <item>
    <p>Use the arrow keys, <key>Home</key>, <key>End</key>, <key>PageUp</key> or <key>PageDown</key> on the keyboard.</p>
   </item>
   <item>
    <p>Choose <gui>Jump to Byte</gui> from the (Main menu) or press <keyseq><key>Ctrl</key><key>J</key></keyseq>,
    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.</p>
   </item>
  </list>
  <p>To delete or zero-out data, use either the <key>Delete</key> or
  <key>Backspace</key> keys. <gui>Cut</gui> operations will also have the
  side-effect of removing or zeroing-out data. This behaviour is different
  depending on whether or not <gui>Insert Mode</gui> is enabled. For more
  information, please review the section below.</p>
 </section>
 <section>
  <title>Insert mode</title>
  <p><gui>Insert Mode</gui> can be toggled on or off by pressing <key>Insert</key>, or by
  clicking the <gui>Toggle insert mode</gui> button in the status bar.</p>
  <p>When <gui>Insert Mode</gui> is enabled, this means data will be added to the file as
  opposed to replacing existing data.</p>
  <p>Unlike traditional text editors, having <gui>Insert Mode</gui> <em>off</em> 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.</p>
  <p>Along these lines, <em>delete</em> operations work differently depending
  upon whether or not <gui>Insert Mode</gui> is enabled.</p>
  <p>If <gui>Insert Mode</gui> is enabled, delete operations (eg, by pressing
  <key>Delete</key>, <key>Backspace</key>, or by a <gui>cut</gui> operation)
  will alter the file length, by removing the data from the file.</p>
  <p>If <gui>Insert Mode</gui> is not enabled, <gui>delete</gui> operations will instead
  zero-out affected bytes within the file, so as to avoid changing the length of
  the file.</p>
 </section>
 <section>
  <title>Setting geometry</title>
  <p>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.</p>
  <p>In GHex, this is called setting <em>geometry</em>. Geometry can be
  customized by right-clicking anywhere in the hex or ASCII panes, and clicking
  <gui>Geometry</gui>, unchecking <gui>Automatic geometry</gui> 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.</p>
 </section>
</page>
