Question

I knew that we can hex edit a file with vi/vim, using the command %!xxd (call *nix hex dump) and %!xxd -r (exit *nix hex dump).

The problem is, if I do some hex-editing in the hex-code area, there is no corresponding cursor displayed in the ascii-code area, and vice-versa.

In contrast, when the file is edited with ghex, there are two cursors, one is with the current edit operation, the other shows the corresponding position in the other panel.

For example, if a text file contains a letter 'f', and I am using ghex to edit it, the cursor in the right panel will show the current character to be edit is 'f', when I move the cursor to the hex value 0x66 in the left panel.

Does this feature already exist in vi/vim/xxd, but I haven't found out?

Was it helpful?

Solution

Just so we're clear, xxd is not a vim command; it is an external program that translates to/from hex dumps. The command %!xxd means 'run the external program xxd, passing it the contents of this file via stdin, and replace the contents of the file with the result.'

From that, I hope you understand that you are not using some special mode of vim to edit these hex dumps. The hex dump is simply the text you see, and you are editing it as a normal text file.

There may be some extension to vim which provides the functionality you are looking for (I haven't looked very hard), but in answer to your question, there is no built-in functionality to do this.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top