我有一个日志文件,当我通过vim打开它时,它看起来不可读,并且在底部已[转换]。[转换]是什么意思?
有没有一种方法可以解决格式问题,使其易于阅读?
这意味着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
请注意最后两个选项fileencoding
&fileencodings
。
第一个是用于当前文件的编码,第二个是用逗号分隔的已识别编码的列表。
因此,当您看到该消息时vim
,告诉您已完成将文件从转换fileencoding
为encoding
。
退房:help fileencoding
或:help encoding
了解其他详细信息。
我在下面找到了该线程,当我回答该问题时,我将该线程用作源。原来的站点现在不见了(在此答案的历史记录中可以访问),因此出于后代考虑,我将该线程的内容移至此处。该链接仍然在Wayback机器。
#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
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句