我有一个日志文件,当我通过 vim 打开它时,它看起来不可读,并且它在底部 [已转换]。[转换]是什么意思?
有没有办法解决格式问题,以便它是人类可读的?
slm*_*slm 39
这意味着vim
检测到文件与您的语言环境给出的字符集不匹配并进行了转换。如果您:set
从内部运行命令vim
:
:set
--- Options ---
autoindent fileformat=dos scroll=7 textwidth=70
background=dark filetype=asciidoc shiftwidth=2 ttyfast
cscopetag helplang=en softtabstop=2 ttymouse=sgr
cscopeverbose hlsearch syntax=asciidoc
noendofline list tabpagemax=3
expandtab ruler textmode
backspace=indent,eol,start
comments=s1:/*,ex:*/,://,b:#,:%,:XCOMM,fb:-,fb:*,fb:+,fb:.,fb:>
cscopeprg=/usr/bin/cscope
fileencoding=utf-8
fileencodings=ucs-bom,utf-8,latin1
Run Code Online (Sandbox Code Playgroud)
注意最后两个选项fileencoding
& fileencodings
。
第一个是用于当前文件的编码,第二个是已识别编码的逗号分隔列表。
所以,当你看到这样的信息vim
告诉你,这是完成了文件,从转换fileencoding
到encoding
。
查看:help fileencoding
或:help encoding
了解更多详情。
我找到了下面的线程,在回答这个问题时我将其用作来源。原始站点现已消失(可在此答案的历史记录中访问),因此为了后代的缘故,我将该线程的内容移至此处。该链接仍在 Wayback Machine 中。
#1 Eli the Bearded January 21st, 2004 - 06:51 pm ET | Report spam
In comp.os.linux.misc, Leon. wrote:
Hide the quote
"Gaétan Martineau" wrote in message
news:E9jLb.2903$
> [ system_notes]$ vi installation_chouette.txt
> What means the [converted] at the bottom of the screen, as in:
> "installation_chouette.txt" [converted] 2576L, 113642C
It means that vim detected that the file did not match the
charset given by your locale and made a conversion. What does
:set
Tell you about "fileencoding" and "fileencodings"? The first is
the encoding used for the current file, the second is a comma
separated list of recognized encodings.
Hide the quote
> This file has accented characters. How can I save the file so that if I
> reload if again, I do not see "converted"?
Figure out what charset you want, and then
:set fileencoding=[charset]
:w
Hide the quote
It means deleting the Microsoft Dos/ Windows CR LF end of lines, to just
LF - unix standard end of lines.
It does not. If you open a file with DOS line ends, vim reports [dos]
after the filename, not [converted]. If you do have a dos file that
you wish to convert to unix line ends, you can
:set fileformat=unix
:w
Elijah
Run Code Online (Sandbox Code Playgroud)
cuo*_*glm 13
在vim
命令模式下,键入:
:help read-messages
Run Code Online (Sandbox Code Playgroud)
你可以看到:
[converted] conversion from 'fileencoding' to
'encoding' done
Run Code Online (Sandbox Code Playgroud)
通常,这意味着 vim 检测到文件与您的语言环境给出的字符集不匹配并进行了转换。
要查看更多详细信息,请尝试:help fileencoding
, :help fileencodings
。
归档时间: |
|
查看次数: |
25160 次 |
最近记录: |