3

Can you recommend a free console hex/ASCII editor with a decent cut function (which would allow to cut blocks e.g. from the middle of a file)? Something which wouldn't be blue all over the place like Norton Commander

4
  • So you want something other than vim/emacs/nano? Why?
    – gardenhead
    Jan 5 '16 at 0:58
  • Since this was migrated from unix.stackexchange.com, could you please tag it appropriately as Unix or Linux, or some particular distro or packaging system? Also, please tag gratis or state a budget. Is "cut" the only feature which you require? If more, please state.them. The more information that you give us, the better we will be able to help you. Ans, since I am quite thick - what do you mean by console? Truly command line only? No Gui? (If Gui, pelsae tag Gnome, Kde, etc) Jan 5 '16 at 9:41
  • @gardenhead: vim and emacs are a bit heavy (AFAIK nano isn't a hex editor and Emacs has a GUI). As said, I want a console application
    – jaam
    Jan 9 '16 at 18:51
  • @Mawg: the cut function seems to be the only thing what I missed in hexedit, which I'm using now. "Command line only" is vague. I want ASCII graphics, as in hexedit, norton commander or (net)hack
    – jaam
    Jan 9 '16 at 23:02
1

Emacs + nhexl-mode

Emacs is a text editor with a lot of features and enormous extensibility.

Emacs has a built-in mode to edit binary file called Hexl mode. However, it only supports overwriting, which is the limitation you want to overcome.

There's a package (plugin) called nhexl-mode which solves this problem. You can install it through Emacs's package manager (menu “Options” → “Manage Emacs Packages”). Nhexl-mode starts in overwrite mode by default, but you can switch to insert mode by running M-x binary-overwrite-mode RET. Even in overwrite mode, deleting works.

You can put the following code snippet in your init file (~/.emacs) to bind the Insert key to toggling overwrite mode in nhexl-mode. (It's a bit more complex than ordinary key bindings because unlike most other modes, nhexl-mode doesn't have a specific keymap by default.)

(unless (boundp 'nhexl-mode-map)
  (defvar nhexl-mode-map (make-sparse-keymap)
    "Keymap used when `nhexl-mode' is active."))
(define-key nhexl-mode-map [insert] 'binary-overwrite-mode)

This may also be of interest if you use nhexl-mode.

3
  • While not what I asked for (Emacs has a GUI), it's good to know this too
    – jaam
    Feb 11 '16 at 20:21
  • @jaam How is it not what you asked for? (Emacs has a GUI, so what? Your question asks for something that works in a terminal, and Emacs does work in a terminal. It'll start in terminal mode if X isn't available, and you can force it to run in a terminal even if X is available with emacs -nw) Feb 11 '16 at 20:26
  • If so, apologies (I don't use Emacs, and assumed it's a GUI-only program). Learning Emacs to be able to cut text from the middle of a file seems a bit of an overkill (but I may be forced to it in the end)
    – jaam
    Feb 11 '16 at 20:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.