简体   繁体   English

为什么-b(binary)选项在vim中不起作用?

[英]Why the -b(binary) option doesn't work in vim?

As vim doc said, I can use the -b option to open a binary file. 正如vim doc所说,我可以使用-b选项打开一个二进制文件。


-b      Binary mode.  File I/O will only recognize <NL> to separate
        lines.  The 'expandtab' option will be reset.  The 'textwidth'
        option is set to 0.  'modeline' is reset.  The 'binary' option
        is set.  This is done after reading the vimrc/exrc files but
        before reading any file in the arglist.  See also
        |edit-binary|.  {not in Vi}

I use this command to open vim: 我使用以下命令打开vim:

$ vim --cmd 'set et' -u NONE -b

I type this command to view options: 我键入以下命令以查看选项:

:set et? bin?

  expandtab
  binary

The et ( expandtab ) option wasn't reset. etexpandtab )选项未重置。 Why? 为什么?
Thanks for your help! 谢谢你的帮助!

Well the issue is, simply, that --cmd -c or +cmd arguments are executed after processing the other flags. 好了,问题很简单,在处理其他标志之后执行--cmd -c或+cmd参数。 This makes sense, as it would not effectively do anything otherwise. 这是有道理的,因为它将无法有效地执行其他任何操作。

 :verbose set et?

would tell you exactly that. 会告诉你确切的。 In case you need a workaround for your particular sample vim +'set binary' (unlikely since et != binary) 如果您需要针对特定​​示例vim +'set binary'的解决方法(不太可能因为et!= binary)

You are right on the docs for --cmd. 您对--cmd的文档很对。 So it comes down to the order in which command line flags are interpreted, which is basically 'undefined'. 因此,它取决于解释命令行标志的顺序 ,这基本上是“未定义”的。 Although 虽然

This is done after reading the vimrc/exrc files but before reading any file in the arglist 这是在读取vimrc / exrc文件之后但在读取arglist中的任何文件之前完成的

could be taken to imply 'before processing other command line arguments'. 可以被认为暗示“在处理其他命令行参数之前”。

Note The '+' commands essentially go with specific files and are (AFAICT) processed in the order in which they appear, even when intermixed with filename arguments. 注意 “ +”命令本质上与特定文件一起使用,并且(AFAICT)按它们出现的顺序进行处理,即使与文件名参数混合使用也是如此。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM