Welcome to Vifm Q&A, where you can ask questions about Vifm usage. Registration is optional, anonymous posts are moderated. GitHub or Google logins are enabled.
0 votes
in vifm by

Currently, I use diff %f %F and then execute :%!xxd in each pane.

1 Answer

0 votes

I would probably use something like this:

:!if [[ $(file --mime %c) =~ 'charset=binary' ]]; then vimdiff -b %b; else vimdiff %f; endif

For this to work, you need appropriate configuration of Vim (this is from sample vimrc or Vim's documentation):

" for handy binary files editing
if &binary
    augroup Binary
        autocmd BufReadPre  * let &bin=1
        autocmd BufReadPost * if &bin | %!xxd
        autocmd BufReadPost * set ft=xxd | endif
        autocmd BufWritePre * if &bin | %!xxd -r
        autocmd BufWritePre * endif
        autocmd BufWritePost * if &bin | %!xxd
        autocmd BufWritePost * set nomod | endif
    augroup END
If you would like to make a bug report or feature request consider using GitHub, SourceForge or e-mail. Posting such things here is acceptable, but this is not a perfect place for them.

Support Ukraine