加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

如何让vim显示BOM为

发布时间:2020-12-15 21:44:36 所属栏目:安全 来源:网络整理
导读:当我查看我们其中一个服务器上的文件时,我看到如下内容: feffsku;qtyproductsku;1 当我下载文件并用vi打开它时,我看不到 feff 当我这样做时:我可以看到 feff但我现在也看到了^ M. feffsku;qty^Mproductsku;1^M 但我不想设置^ M.我只是想看看 feff. 另一个
当我查看我们其中一个服务器上的文件时,我看到如下内容:

<feff>sku;qty
productsku;1

当我下载文件并用vi打开它时,我看不到< feff>

当我这样做时:我可以看到< 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中所述的文件?

解决方法

:help’bomb’解释了Vim的行为:

When Vim reads a file and ‘fileencodings’ starts with “ucs-bom”,a
check for the presence of the BOM is done and ‘bomb’ set accordingly.
Unless ‘binary’ is set,it is removed from the first line,so that you
don’t see it when editing.

所以,

:set fencs-=ucs-bom

会关闭它,但编码检测也会被打破!根据我的实验,显式编码设置(via:edit enc = ucs2-le)也设置’炸弹’并删除< feff>标记.所以,这条大道无处可去.

备择方案

>正如您所知,以二进制模式编辑.我不推荐它,因为它有缺点.
>在状态行中包含指示.你必须寻找其他地方,但它总是可见的,而不仅仅是在文档的开头.强烈推荐作为Vim中的正确方法?.也很容易实现:

set statusline+= %{&bomb?'BOM':''}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读