当我查看我们其中一台服务器上的文件时,我看到类似这样的内容:
<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-file是/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
中所述的其他文件?
答案 0 :(得分:5)
:help 'bomb'
解释了Vim的行为:
当Vim读取文件和&#39; fileencodings&#39;以&#34; ucs-bom&#34;开头,a 检查BOM的存在是否已完成并且“炸弹”#39;相应地设定。 除非&#39;二进制&#39;设置,它从第一行删除,以便你 编辑时没有看到它。
所以,
:set fencs-=ucs-bom
会将其关闭,但编码检测也会被破坏!根据我的实验,显式编码设置(通过:edit ++enc=ucs2-le
)也会设置'bomb'
并删除<feff>
标记。所以,这条道路无处可去。
set statusline+=\ %{&bomb?'BOM':''}