如何让vim将BOM显示为<;feff>;
当我查看我们其中一台服务器上的文件时,我看到如下内容:如何让vim将BOM显示为<;feff>;,vim,Vim,当我查看我们其中一台服务器上的文件时,我看到如下内容: <feff>sku;qty productsku;1 但是我不想设置^M。我只想看看。 另一个例子是另一个文件中的 我如何设置vim来显示这些特殊角色 ~z~编辑~ 命令vi--version告诉我以下内容: VIM - Vi IMproved 7.0 (2006 May 7, compiled Aug 4 2010 07:21:08) 它还表示系统vimrc文件是/etc/vimrc,具有以下内容: if v:lang
<feff>sku;qty
productsku;1
但是我不想设置^M
。我只想看看
。
另一个例子是另一个文件中的
我如何设置vim来显示这些特殊角色
~z~编辑~
命令vi--version告诉我以下内容:
VIM - Vi IMproved 7.0 (2006 May 7, compiled Aug 4 2010 07:21:08)
它还表示系统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
如果v:lang=~“utf8$”| | v:lang=~“UTF-8$”
设置文件编码=utf-8,拉丁文1
恩迪夫
设置术语=内置的ansi
设置nocompatible“使用Vim默认值(更好!)
设置bs=缩进、下线、开始“允许在插入模式下对所有内容进行退格
“设置ai”始终将自动缩进设置为打开
“设置备份”保留备份文件
设置viminfo='20,\'50'读/写一个.viminfo文件,不要存储更多
“超过50行寄存器
设置历史记录=50“保留50行命令行历史记录
“设置标尺”始终显示光标位置
“仅当在支持自动命令的情况下编译时才执行此部分
如果有(“自动MD”)
红帽子
在文本文件中,始终将文本宽度限制为78个字符
autocmd BufRead*.txt设置tw=78
编辑文件时,始终跳转到最后一个光标位置
autocmd BufReadPost*
\如果行(“\”)>0和行(“\”):help“bomb”
解释了Vim的行为:
当Vim读取一个文件并且“文件编码”以“ucs bom”开头时
检查是否存在物料清单,并相应设置“炸弹”。
除非设置了“binary”,否则它将从第一行中删除,以便
编辑时看不到它
所以
会关闭此功能,但编码检测也会被破坏!根据我的实验,显式编码设置(通过:edit++enc=ucs2 le
)也会设置“炸弹”
,并删除
标记。所以,这条路什么也走不到
选择
- 如您所知,在二进制模式下编辑。我不推荐它,因为它有缺点
- 包括状态行中的指示。您必须查看其他地方,但它始终可见,而不仅仅是在文档的开头。强烈推荐使用正确的方法™ 在维姆。也很容易实现:
依我看,你想要的功能是合理的,但不幸的是,据我所知,没有任何方法可以实现它。Vim试图隐藏行尾和BOM表(如果存在),以便只关注文本。最好的办法可能是研究这个选项;你可以将其作为定制的一部分。奇怪的是,它必须是可能的,因为我在我们的大多数服务器上都有这种行为。但我不知道它是哪种配置。~/.vimrc与我的相同,因此服务器上必须加载另一个文件,该文件具有我需要的设置。嗯,很有趣。我想到的一种可能性是,您的服务器上可能有旧版本的vim,它们不知道BOM,因此它最终显示为普通文本。我记得不久前我在IBM工作的时候,我们有很多服务器都有vim/vi的非常旧的版本(有一个例子是Vi3.1,IIRC),这些版本的功能非常少,令人失望。在我们的服务器上,vim-vi改进了7.0(2006年5月7日,编译于2010年8月4日07:21:08)
,在我的mac上,vim-vi改进了7.3(2010年8月15日,编译2015年7月9日23:58:42)因此它们之间没有太大的距离您知道一个编辑器可以在文本itslef中显示BOM吗?
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
:set fencs-=ucs-bom
set statusline+=\ %{&bomb?'BOM':''}