harpo
harpo

Reputation: 43168

How do I insert (not overwrite) a byte in hexl-mode?

All of the hexl-insert- commands overwrite the byte at point. It makes no difference whether overwrite-mode is on.

I need to actually insert a new byte at point, moving everything else down.

How can I do this in emacs?

Upvotes: 14

Views: 5277

Answers (2)

Endle_Zhenbo
Endle_Zhenbo

Reputation: 576

I can't insert characters directly in nhexl-mode either. I have to follow such approach:

  1. Open file. M-x nhexl-mode then M-x nhexl-nibble-edit-mode
  2. Type only one character in another editor, copy it
  3. Move the cursor in Emacs, C-y to yank this character and adjust file format
  4. Move the cursor to fix hex

For example, If I want to insert 5300 to represent S, I need to press C-y to get 5353, then edit it into 5300

I'm using GNU Emacs 26.1 (build 1, x86_64-w64-mingw32) on Windows 10 and nhexl 1.2

Upvotes: 0

Stefan
Stefan

Reputation: 28531

You might prefer nhexl-mode, which lets you edit the file as if it was not hexlified (basically, the hexlification in nhexl-mode is done on-the-fly during redisplay), so you can insert/remove text without any difficulty.

Upvotes: 7

Related Questions