在 gvim 中显示空白字符

发布于 2024-10-17 04:29:47 字数 119 浏览 3 评论 0原文

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

Is there an easy way to display whitespace characters such as space and tab in gvim? Something like what is implemented in Gedit, Geany, Komodo, and other GUI editors where (when the option is turned on) spaces show as a muted or greyed-out '.' and tabs as '-->'.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

薄荷梦 2024-10-24 04:29:47

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

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

Check out listchars and list options in Vim. An example use of this feature:

" part of ~/.vimrc
" highlight tabs and trailing spaces
set listchars=tab:>-,trail:-
set list
谷夏 2024-10-24 04:29:47

如果您首先启用 Unicode,您可以使用任何您想要的字符

set encoding=utf-8

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

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

了解有关此设置的更多信息 http://vim.wikia.com/wiki/Highlight_unwanted_spaces

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

You can use any characters you wish if you enable Unicode first

set encoding=utf-8

One line I use (put in ~/.vimrc):

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

Learn more about this setting at http://vim.wikia.com/wiki/Highlight_unwanted_spaces

The color of these characters is controlled by your color scheme.

音盲 2024-10-24 04:29:47

这是我的一些与空白相关的设置。

使用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 \+\)\(\%#\)\@!')

希望这些有所帮助!

Here are some of my settings pertaining whitespace.

Use F11 to toggle between displaying whitespace characters or not:

noremap <F11> :set list!<CR>

How to show whitespace characters when list is set:

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

Highlight special characters in yellow:

highlight SpecialKey term=standout ctermbg=yellow guibg=yellow

Highlight redundant spaces (spaces at the end of the line, spaces before or after tabs):

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

Hope these help!

嗳卜坏 2024-10-24 04:29:47

这对我来说效果很好:

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

This works well for me:

"trailing white space detection
highlight WhitespaceEOL ctermbg=yellow guibg=yellow
match WhitespaceEOL /\s\+$/
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文