4

我发现的每个与编码相关的问题都是关于如何重新编码文件。

但是,我的情况恰恰相反——有可能让 vim 根本不重新编码文件吗?(以及如何,如果是的话?)

有时是写[converted]在状态栏,总是错过。但是,我将终端设置为与编辑文件相同的编码,因此,我根本不需要重新编码。

4

2 回答 2

7

利用

vim -b "myfile.type"

以二进制模式编辑。您还可以设置

:set binary

或者如果你像我一样懒惰

:se bin

在 vim 中编辑文件之前(适用于当前缓冲区)

:he `binary`


                     *'binary'* *'bin'* *'nobinary'* *'nobin'*
'binary' 'bin'      boolean (default off)
            local to buffer
            {not in Vi}
    This option should be set before editing a binary file.  You can also
    use the |-b| Vim argument.  When this option is switched on a few
    options will be changed (also when it already was on):
        'textwidth'  will be set to 0
        'wrapmargin' will be set to 0
        'modeline'   will be off
        'expandtab'  will be off
    Also, 'fileformat' and 'fileformats' options will not be used, the
    file is read and written like 'fileformat' was "unix" (a single <NL>
    separates lines).
    The 'fileencoding' and 'fileencodings' options will not be used, the
    file is read without conversion.
于 2011-03-28T19:52:42.637 回答
1

如果您正在编辑二进制文件,则需要 sehe 建议的内容,binary.

如果您正在编辑文本文件,那么您可能需要更改fileencodings,或者如果问题是 vim 没有正确检测到终端编码,encoding.

于 2011-03-28T20:12:51.160 回答