tweak: The word processor of hex editors

Is it time for a hex editor? It’s time for a hex editor. Or maybe it’s time for a word processor.O_o

I saved tweak for later in the game, because I could see by the home page that it was intended to run with emacs-style key commands. That always takes me a little bit to re-learn.

It’s not as bad as I make it sound though. The majority of tweak’s controls and commands are fairly straightforward, and some are quite useful.

2014-11-07-2sjx281-tweak

After working with tweak for a few minutes, I came to the realization that tweak behaves less like a hex editor than some of its counterparts, and behaves more like a word processor than I expected.

For example, it has an insert mode and an overwrite mode, meaning you can press ENTER and jump to the ASCII side of the screen, and just start typing. Overwritten text will behave much as you might expect, but inserted text will cause the entire remainder of the display to shuffle out to the right as you go.

tweak has a copy-and-paste function too, and you can see that at work in the screenshot. Highlight a section with CTRL+@, then write it to a buffer with ALT+W. Move to a new spot, and remembering to either insert or overwrite, drop it into place with CTRL+Y.

If you’re in insert mode after you highlight a passage, CTRL+W will cut that section from the section, so you have a hex cut-and-paste-slash-cut-and-delete function too.

tweak borrows more from the word processor field with forward and back search functions, hotkeys to go to the start and end of the file, a jump-to-address command and a few more little bonuses.

Perhaps best of all, you can tell tweak to adjust its display on-the-fly, with the CTRL+X+w combination. So if you want to take advantage of every one of your precious 280 columns🙄, tweak will accommodate.

Commands can be customized in tweak, and the easiest way to do that would be

tweak -D > ~/.tweakrc

tweak will write its default configuration to STDOUT; send that into a configuration file and you can edit it to fit your personal preferences. You could even conceivably edit it with tweak. How meta. …😐

The tweak home page suggests tweak can handle massive cut-and-pastes and will run reasonably light by “lazy loading.” But if I feed tweak a zero-byte file, ps_mem.py still says it’s taking up over 2Mb of space. So likely if you’re working in a big file or making very big edits, you might need more.

I like tweak for taking the word processor route instead of just assuming the standard hex editor role. It doesn’t have some of the on-screen features that the others offer, but if you squint at the screen while you’re editing, you can almost imagine it’s 1986, and you’re using WordStar.😉