当我在其中一台服务器上查看文件时,会看到类似以下内容的内容:
<feff>sku;qty
productsku;1
当我下载文件并用vi打开它时,看不到
<feff>
当我执行
:e ++bin
时,我可以看到<feff>
,但是现在我也看到了^ M<feff>sku;qty^M
productsku;1^M
但是我不想设置
^M
。我只想看<feff>
。另一个示例是我在另一个文件中拥有的
<80>
。我该如何设置vim来显示那些特殊字符?
〜编辑〜
命令
vi --version
告诉我以下内容:VIM - Vi IMproved 7.0 (2006 May 7, compiled Aug 4 2010 07:21:08)
它还说system-vimrc文件是
/etc/vimrc
,它具有以下内容:if v:lang =~ "utf8$" || v:lang =~ "UTF-8$"
set fileencodings=utf-8,latin1
endif
set term=builtin_ansi
set nocompatible " Use Vim defaults (much better!)
set bs=indent,eol,start " allow backspacing over everything in insert mode
"set ai " always set autoindenting on
"set backup " keep a backup file
set viminfo='20,\"50 " read/write a .viminfo file, don't store more
" than 50 lines of registers
set history=50 " keep 50 lines of command line history
set ruler " show the cursor position all the time
" Only do this part when compiled with support for autocommands
if has("autocmd")
augroup redhat
" In text files, always limit the width of text to 78 characters
autocmd BufRead *.txt set tw=78
" When editing a file, always jump to the last cursor position
autocmd BufReadPost *
\ if line("'\"") > 0 && line ("'\"") <= line("$") |
\ exe "normal! g'\"" |
\ endif
augroup END
endif
if has("cscope") && filereadable("/usr/bin/cscope")
set csprg=/usr/bin/cscope
set csto=0
set cst
set nocsverb
" add any database in current directory
if filereadable("cscope.out")
cs add cscope.out
" else add database pointed to by environment
elseif $CSCOPE_DB != ""
cs add $CSCOPE_DB
endif
set csverb
endif
" Switch syntax highlighting on, when the terminal has colors
" Also switch on highlighting the last used search pattern.
if &t_Co > 2 || has("gui_running")
syntax on
set hlsearch
endif
if &term=="xterm"
set t_Co=8
set t_Sb=^[[4%dm
set t_Sf=^[[3%dm
endif
我复制了此代码并将其添加到我的
~/.vimrc
中,但是这些更改都没有实现我想要的功能。如果有一些情况,那么我可能也必须处理这些问题。有谁知道在编辑文件时是否会读取
vi --version
中指定的文件以外的其他文件? 最佳答案
:help 'bomb'
解释了Vim的行为:
所以,
:set fencs-=ucs-bom
会关闭此功能,但随后编码检测也会中断!根据我的实验,显式编码设置(通过
:edit ++enc=ucs2-le
)还设置了'bomb'
并删除了<feff>
标记。因此,这种途径无济于事。备择方案
set statusline+=\ %{&bomb?'BOM':''}