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
Asked
Active
Viewed 133 times
1
-
5Possibly 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 Answers
4
Because expanding tabs to spaces in the context of a binary file is almost always wrong:
- Tabs may not represent whitespace at all; they may just be bytes which happen to be
\t
. Expansion would alter the meaning. - The offsets into the file may need to be preserved, which
expandtab
does not do. - 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
-
1And if you really need to have this, you can just `:setl et` again, hopefully aware of what you're doing. – Ingo Karkat Jan 05 '15 at 08:53