Editing a file
Prev | Chapter 4. Using Bless | Next

## Editing a file

### Basic editing operations

#### Changing the current cursor position

You can move the cursor in two ways:

Using the keyboard
  - Pressing the Up Arrow key moves the cursor to the byte just above the current one.
  - Pressing the Down Arrow key moves the cursor to the byte just below the current one.
  - Pressing the Left Arrow key moves the cursor to the previous digit of the current byte. If the cursor was at the first digit of a byte, it is moved to the last digit of the previous byte.
  - Pressing the Right Arrow key moves the cursor to the next digit of the current byte. If the cursor was at the last digit of a byte, it is moved to the first digit of next byte.
  - Pressing the Page Up key moves the cursor to the byte which is one page before the current position.
  - Pressing the Page Down key moves the cursor to the byte which is one page after the current position.
  - Pressing the Home key moves the cursor to the first byte in the file.
  - Pressing the End key moves the cursor one byte after the last byte in the file.
Using the mouse
  Clicking on a digit of a byte moves the cursor to that byte and digit.

### Note

If the new cursor position is outside the currently visible page of data, the view scrolls automatically so that the new cursor position is made visible.

#### Moving the cursor to a specific position

To access the Go to Offset Bar use: Search → Go to Offset (Ctrl+G).

Figure 4.3. Go to Offset Bar

To move the cursor to a specific position in the file:

1. Type the offset in the Offset text entry (in the desired number format). if the typed offset starts with '0x' it is considered hexadecimal, if it starts with '0' it is considered octal, otherwise it is considered decimal.

2. Press the Go to Offset button

#### Selecting a range of data

There are three ways to select a range of data from the file you are editing:

Using the keyboard
  - Position the cursor at one end of the range you want to select.
  - Hold down the Shift key and move the cursor to the other end of the range using the keyboard. As you move the cursor, the currently selected data range will be highlighted.
  - Release the Shift key.
Using the mouse
  - Position the cursor at one end of the range you want to select.
  - Hold down the Left mouse button and move the cursor to the other end of the range using the mouse. As you move the cursor, the currently selected data range will be highlighted.
  - Release the Left mouse button.
  - ...alternatively, while pressing the Shift key, position the mouse pointer over the other end of the selection and click using the Left mouse button.
Using the Select Range Bar

  To access the Select Range Bar use: Edit → Select Range (Ctrl+Shift+R).

  Figure 4.4. Select Range Bar

  To select a range:

  1. Type the starting offset in the from text entry (in the desired number format). if the typed offset starts with '0x' it is considered hexadecimal, if it starts with '0' it is considered octal, otherwise it is considered decimal.

  2. Type the ending offset in the to text entry (in the desired number format). if the typed offset starts with '0x' it is considered hexadecimal, if it starts with '0' it is considered octal, otherwise it is considered decimal.

     Instead of specifying an absolute ending offset you can specify the length of the selection. To do this type the length in the to text entry, prepending it with either '+' or '-'. The '+' or '-' specify the direction of the selection: '+' means select towards the end of the file and '-' means select towards the beginning. The selected range always contains the starting offset.

Selecting a range of data has another useful effect: all the patterns matching the selected data in the file are highlighted, thus providing a quick way to find or emphasize patterns. The color of the highlighting can be changed using Layout files (see the section called “Layout Files”). This feature can be turned off in the Preferences Dialog (see the section called “General Preferences”).

### Note

The patterns matching the selected data are highlighted only if the selected data size is at most 1024 bytes.

#### Toggling Overwrite/Insert edit mode

By pressing the Insert key on the keyboard or by clicking on the edit mode statusbar, you can change the edit mode Bless is currently in. The edit mode determines what happens when you add new data to the file. There are two available modes:

Insert Mode
  The new data is inserted at the current cursor position. Bless automatically makes space for the new data.
Overwrite Mode
  The new data overwrites the old data, starting from the current cursor position.

Figure 4.5. Edit mode statusbar display

The current edit mode is displayed at the far right in the statusbar.

#### Changing the statusbar number base

You can change the number base of the information displayed in the statusbar (current offset, current selection). Clicking on the Offset or Selection information in the statusbar cycles among Hexadecimal, Decimal and Octal number bases. You can distinguish the current number base by checking the prefix of displayed numbers. A "0x" prefix denotes Hexadecimal, a "0" prefix denotes Octal and no prefix denotes Decimal.

Figure 4.6. Statusbar number base

#### Modifying the data

You can directly modify the data in a file by using the keyboard:

Inserting a new byte at a specific position
  - Make sure you are in Insert Mode.
  - Move the cursor to the first digit of desired position.
  - Press the keys which correspond to the digits of the desired byte. Each keypress automatically moves the cursor one position to the right.
Modifying an existing byte
  - Make sure you are in Overwrite Mode (only required if you want to modify the first digit of a byte).
  - Move the cursor to desired byte/digit position.
  - Press the keys which correspond to the digits of the desired byte. Each keypress automatically moves the cursor one position to the right.
Appending data to the end of the file
  - Move the cursor to the position just after the last byte in the file.
  - Press the keys which correspond to the digits of the desired byte. Each keypress automatically moves the cursor one position to the right.

### Note

Each area accepts only certain digits (eg the hexadecimal area accepts only 0-9 and A-F). If a key (representing a digit) is pressed in an area that doesn't accept it, the keypress is ignored.

### Clipboard operations

Bless features an advanced system to handle clipboard operations.

#### Copy and Cut operations

To copy the selected data to the clipboard use: Edit → Copy (Ctrl+C).

To cut the selected data from the file and copy it to the clipboard use: Edit → Cut (Ctrl+X).

When copying or cutting data, that data becomes available to Bless and other applications as well. Bless can offer its data to other applications in two main formats:

Raw bytes

  Bless can offer the selected data as raw bytes to applications that can handle it, for example other hex editors. This is the format Bless uses when interacting with itself (for example when you copy from a tab and paste into another).

UTF-8 string

  Bless can offer a string representation of the selected data in various number bases or UTF-8 text. The number base is determined by the type of the area that has the focus at the end of the selection action for the cut/copied data. For example if that area is hexadecimal, the offered string will contain the hexadecimal string representation of the selected data. If the ending area is the text area, the offered string will contain the UTF-8 text represented by the selected data (if possible).

#### Paste operation

To paste data from the clipboard to the current cursor position use: Edit → Paste (Ctrl+V).

The value of the Overwrite/Insert mode, affects the way paste operations function. If the mode is Insert, the pasted data is inserted at the current cursor position. If the mode is Overwrite, the pasted data overwrites the data from the cursor position and on, as needed.

Pasted data can originate from Bless itself or some other application. Bless can accept data in two formats:

Raw bytes

  This is the format Bless uses when interacting with itself (for example when you copy from a tab and paste into another). External applications that offer raw bytes are usually other hex editors.

UTF-8 string

  Bless can accept data as a UTF-8 string (for example, from a text editor). It tries to parse the data and convert it to raw bytes according to the type of the area that currently has the focus. For example if the focus is in an octal area, Bless will try to parse the string as a sequence of bytes represented in octal format. If the parse fails, the data will be inserted as UTF-8 text (as if they had been pasted into a text area).

### Undo/Redo operations

To undo previous actions use: Edit → Undo (Ctrl+Z).

To redo previously undone actions use: Edit → Redo (Shift+Ctrl+Z).

Prev | Up | Next
Data View basics | Home | Searching and Replacing in files