繁体   English   中英

在gvim中显示空白字符

[英]Show whitespace characters in gvim

有没有一种简单的方法可以在gvim中显示空格和制表符等空白字符? 类似于Gedit,Geany,Komodo和其他GUI编辑器中实现的内容(当选项打开时)空格显示为静音或灰色'。' 和标签为' - >'。

查看Vim中的listcharslist选项。 此功能的一个示例用法:

" part of ~/.vimrc
" highlight tabs and trailing spaces
set listchars=tab:>-,trail:-
set list

如果先启用Unicode,则可以使用任何所需的字符

set encoding=utf-8

我使用的一行(放入~/.vimrc ):

set list listchars=tab:→\ ,trail:·

有关此设置的详情,请访问http://vim.wikia.com/wiki/Highlight_unwanted_spaces

这些字符的颜色由您的配色方案控制。

以下是我的一些关于空白的设置。

使用F11在显示空格字符之间切换:

noremap <F11> :set list!<CR>

如何在设置list时显示空白字符:

set listchars=eol:$,tab:>-,trail:.,extends:>,precedes:<,nbsp:_

突出显示黄色的特殊字符:

highlight SpecialKey term=standout ctermbg=yellow guibg=yellow

突出显示冗余空格(行尾的空格,制表符之前或之后的空格):

highlight RedundantSpaces term=standout ctermbg=Grey guibg=#ffddcc    
call matchadd('RedundantSpaces', '\(\s\+$\| \+\ze\t\|\t\zs \+\)\(\%#\)\@!')

希望这些帮助!

这适合我:

"trailing white space detection
highlight WhitespaceEOL ctermbg=yellow guibg=yellow
match WhitespaceEOL /\s\+$/

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM