13 votes

How to edit binary files with Vim?

TL;DR Answer Open the file with Vim in binary mode: vim -b <file_to_edit> In Vim, get into hex editing mode like so: :%!xxd -p To save: :%!xxd -p -r :w The first line will convert the ...
Hintron's user avatar
  • 239
9 votes

How to edit binary files with Vim?

Use the "bvi" editor. http://bvi.sourceforge.net/ (It's in every Linux repository.) $ apt-cache show bvi [snip] Description-en: binary file editor The bvi is a display-oriented editor for binary ...
RonJohn's user avatar
  • 191
7 votes

Where is xxd in Windows gvim?

It is distributed with Vim (as xxd.exe), along with diff.exe. So it exists and should work on Windows. You don't need to install anything separately, as it is already bundled with Vim (at least in ...
mMontu's user avatar
  • 6,640
6 votes

start vi automatically in hex mode

To start vim automatically in hex mode when editing a.out, put an autocommand like this one in your ~/.vimrc: au BufReadPost a.out silent %!xxd A more complete explanation with examples can be found ...
garyjohn's user avatar
  • 6,309
3 votes

Why is `%!xxd -r` result wrong while `xxd -r` from console with the same input works correctly?

Edit: notice after posting there's already this answer in the comments. Run vim in binary mode as vim -b asterix. I think the problem has something to do with conversions caused by encoding/...
avysk's user avatar
  • 196
3 votes

Vim hex editor with xxd not working as intended

This will happen if you start editing the xxd-dumped version of the binary file, in which case Vim will assume a UTF-8 encoding (which you can confirm with :set fenc? returning fileencoding=utf-8). ...
filbranden's user avatar
  • 28.8k
1 vote

Vim hex editor with xxd not working as intended

Here's what I have in my ~/.vimrc to allow quite comfortable and issue-free editing of binary files, which are narrowed down to *.bin and *.hex files in the vimcode below, but that can be adjusted as ...
dsimic's user avatar
  • 217
1 vote

Avoiding unwanted TextChanged events to avoid 'modified' (hex editing)

*TextChanged* TextChanged After a change was made to the text in the current buffer in Normal mode. That is after |b:changedtick| has changed (also when that ...
dedowsdi's user avatar
  • 6,258
1 vote

How to edit binary files with Vim?

This looks like a handy little vim plugin that does the job using a temporary file which it writes back and forth for you automatically. Some years ago I found a similar plugin which I adapted and ...
Tim's user avatar
  • 426

Only top scored, non community-wiki answers of a minimum length are eligible