以下是我的问题:
when I open the file, I get this message from vim:
"myfilename.sql" [converted] 78565L, 10487381C
if I do
:set
i get:Options backspace=2 colorcolumn=+1 formatoptions=qc scrolloff=15 smartindent textwidth=80 visualbell backup expandtab ignorecase shiftwidth=4 syntax=sql ttyfast t_vb= bomb filetype=sql number showcmd tabstop=4 ttymouse=sgr backupdir=~/.vim/backup comments=s1:/*,mb:*,ex:*/,:--,:// define=\c\<\(VARIABLE\|DECLARE\|IN\|OUT\|INOUT\)\> directory=~/.vim/tmp fileencoding=utf-8 fileencodings=utf-8,ucs-bom,default,latin1 matchpairs=(:),{:},[:],<:> omnifunc=sqlcomplete#Complete viminfo='10,"100,:20,%,n~/.viminfo
I have the characters visible like this:
I found that if I reload & force encoding latin1 with
:e ++enc=latin1
I get right accents, but not all:So I found out (the only solution) to get all the right visible encoding is to manually force back to utf8:
:set encoding=utf8
then I get:if I do
:set
i get:--- Options --- backspace=2 encoding=utf-8 formatoptions=qc scrolloff=15 smartindent textwidth=80 visualbell backup expandtab ignorecase shiftwidth=4 syntax=sql ttyfast t_vb= colorcolumn=+1 filetype=sql number showcmd tabstop=4 ttymouse=sgr backupdir=~/.vim/backup comments=s1:/*,mb:*,ex:*/,:--,:// define=\c\<\(VARIABLE\|DECLARE\|IN\|OUT\|INOUT\)\> directory=~/.vim/tmp fileencoding=latin1 fileencodings=utf-8,ucs-bom,default,latin1 matchpairs=(:),{:},[:],<:> omnifunc=sqlcomplete#Complete viminfo='10,"100,:20,%,n~/.viminfo
As you can see, I see
fileencoding=latin1
so I try to force it to utf8::set fileencoding=utf-8
. I save it:wq
and whenever I want to re-open it nothing has changed, I still have to do all of this to get a proprer display with good accents!The only thing I want from now is to save it so that I can re-open it without having all of this to do to get it right. What should I do?
:set encoding=utf8
然后使用:e ++enc=latin1 filename
会发生什么? - Ingo Karkat:set encoding=utf8
时,它会更改显示但不是正确的(就像使用:set encoding=latin1
一样),如果我尝试:e ++enc=utf-8 otherfile.sql
,它会创建一个新的空文件... - Olivier Pons:w
搞乱了文件编码。你能否在终端中展示file yourFile
或者file -i yourFile
的输出? - Kentset encoding?
的输出是什么? - Kent