当我查看我们其中一台服务器上的文件时,我看到如下内容:
<feff>sku;qty
productsku;1
Run Code Online (Sandbox Code Playgroud)
当我下载文件并用vi打开它时,我看不到 <feff>
我什么时候:e ++bin
能看到,<feff>
但我现在也看到了^ M.
<feff>sku;qty^M
productsku;1^M
Run Code Online (Sandbox Code Playgroud)
但我不想设置^M
.我只是想看看<feff>
.另一个例子是<80>
我在另一个文件中.
我怎样才能设置vim来向我展示那些特殊的字符?
〜编辑〜
该命令vi --version
告诉我以下内容:
VIM - Vi IMproved 7.0 (2006 May 7, compiled Aug 4 2010 07:21:08)
Run Code Online (Sandbox Code Playgroud)
它还说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
Run Code Online (Sandbox Code Playgroud)
我复制了这个并将其添加到我的中,~/.vimrc
但这些更改都不是我想要的.如果有一些情况,我可能不得不玩这些.
有没有人知道vi --version
在编辑文件时是否还有其他文件会被读取?
:help 'bomb'
解释了Vim的行为:
当Vim读取文件并且'fileencodings'以"ucs-bom"开头时,检查是否存在BOM,并相应地设置'炸弹'.除非设置了'binary',否则它将从第一行中删除,因此您在编辑时不会看到它.
所以,
:set fencs-=ucs-bom
Run Code Online (Sandbox Code Playgroud)
会关闭它,但编码检测也会被打破!根据我的实验,显式编码设置(via :edit ++enc=ucs2-le
)也设置'bomb'
和删除<feff>
标记.所以,这条大道无处可去.
set statusline+=\ %{&bomb?'BOM':''}
Run Code Online (Sandbox Code Playgroud)