1

In Vim, why does including set binary after set expandtab unset expandtab? I just had this issue for the first time, and here is a comment from another SO user in the past having the same problem: How can I find out why vim keeps changing my expandtab setting

Community
  • 1
  • 1
Trindaz
  • 17,029
  • 21
  • 82
  • 111
  • 5
    Possibly because it just says so in the docs? http://vimdoc.sourceforge.net/htmldoc/options.html#'binary' and it would seem reasonable that when editing a file in binary mode you would not want character substitution of any kind to happen while you edit. – Trindaz Jan 04 '15 at 21:05
  • This cost me a .vimrc bijction :( – Ciro Santilli OurBigBook.com Feb 04 '15 at 12:25

1 Answers1

4

Because expanding tabs to spaces in the context of a binary file is almost always wrong:

  1. Tabs may not represent whitespace at all; they may just be bytes which happen to be \t. Expansion would alter the meaning.
  2. The offsets into the file may need to be preserved, which expandtab does not do.
  3. There is little actual benefit to any sort of automatic whitespace manipulation when editing binary files; binary files are assumed to be mostly binary rather than text, so things like indentation are non-issues to begin with.
Kevin
  • 28,963
  • 9
  • 62
  • 81