Can't write when using :Hexmode, -b works
Hi,
thanks for this plugin, very handy!
I seem to have issues when using the :Hexmode command however. When I save a file that was opened using the -b command line option it works as intended but when I open the file normally and then run :Hexmode theres always issues saving the file. Vim complains about a 'Conversion Error in Line X' in that case and the file ends up corrupted. Anyone having the same issue?
Thanks again, Normen
I just tested it and it worked fine for me. Did you try disabling any plugins you might have installed?
I've had the same issue, but only due to loading a binary file in 'nobinary' mode (my mistake). It's reproducible even when bypassing the vimrc and loading hexmode.vim directly (vim -u hexmode.vim).
I am testing using a PNG file, on Linux.
Disabling the binary mode detection (line 79) shows that everything is fine if the file is loaded with :e ++bin $file, but not with :e ++nobin $file.
When writing after running :Hexmode vim prints the following.
CONVERSION ERROR in line 3;[noeol] 3L, 87C written
Additionally some of the bytes changed (a d99f pair was changed to bf, the trailing 0a was removed).
I imagine this is due to the conversions that 'binary' prevents, but I'm not experienced enough with vim's internals to know which in particular.
I think I had a similar problem and created this to get things working based on some info I found online.
" correctly save edits to hex file
function! Hexsave()
set noendofline
%s#^[^:]*: \(\%(\x\+ \)\+\) .*#\1# | %!xxd -r -p
%!xxd
write
endfunction
command! Hexsave call Hexsave()