Saturday, May 23, 2015

Re: What vim does it differently when -b is enabled?

On 2015-05-23 17:32, Peng Yu wrote:
> -b Binary mode. A few options will be set that makes it
> possible to edit a binary or executable file.
>
> Could anybody help explain this and provide a minimal binary file
> that shows the difference between with -b and without -b? Thanks.

":help -b" gives a little more detail but I'm not sure whether I've
found a bug.

tim@laptop:~/tmp$ cat testvimrc
set nocompatible
set modeline
set sw=4
set ts=4
set et
tim@laptop:~/tmp$ xxd testfile
0000000: 2f2a 2076 693a 2073 6574 2065 7870 616e /* vi: set expan
0000010: 6474 6162 2073 773d 3220 7473 3d32 3a20 dtab sw=2 ts=2:
0000020: 2a2f 0d0a 6669 7273 7420 6c69 6e65 0d0a */..first line..
0000030: 0973 6563 6f6e 6420 6c69 6e65 2077 6974 .second line wit
0000040: 6820 7461 620d 0a h tab..


When when opened with

vi -u testvimrc testfile

it has the following settings

:set modeline? ts? et? sw? bin? ff?
modeline
tabstop=2
expandtab
shiftwidth=2
nobinary
fileformat=dos

And when opened with

vi -u testvimrc -b testfile

it has the following settings

:set modeline? ts? et? sw? bin?
modeline
tabstop=2
expandtab
shiftwidth=2
binary
fileformat=unix

Based on the ":help -b", I would have expected that 'noexpandtab' and
'nomodeline' would appear in that output, and that my ts/sw would be
4 (set in the vimrc) rather than the ts/sw from the file's modeline
contents. It does correctly prevent munging of CR/LF by setting
ff=unix and 'binary'.

-tim




--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments: