使 Vim 将所有空格显示为字符 [英] Make Vim show ALL white spaces as a character

查看:44
本文介绍了使 Vim 将所有空格显示为字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我找不到让 Vim 将所有空格显示为字符的方法.我发现的只是制表符、尾随空格等.

I can't find a way to make Vim show all white spaces as a character. All I found was about tabs, trailing spaces etc.

推荐答案

正如其他人所说,你可以使用

As others have said, you could use

:set list

这将结合

:set listchars=...

显示不可见字符.
现在,没有可用于显示空白的显式选项,但在 listchars 中,您可以设置一个字符以显示除空白之外的所有内容.例如,我的看起来像这样

display invisible characters.
Now, there isn't an explicit option which you can use to show whitespace, but in listchars, you could set a character to show for everything BUT whitespace. For example, mine looks like this

:set listchars=eol:$,tab:>-,trail:~,extends:>,precedes:<

所以,现在,在你使用之后

so, now, after you use

:set list

所有没有明确显示为其他东西的东西,实际上都是一个普通的旧空白.

everything that isn't explicitly shown as something else, is then, really, a plain old whitespace.

像往常一样,要了解 listchars 的工作原理,请使用帮助.它提供了有关可以显示哪些字符(例如尾随空格)以及如何显示的重要信息:

As usual, to understand how listchars works, use the help. It provides great information about what chars can be displayed (like trailing space, for instance) and how to do it:

:help listchars

添加一个切换开关可能会有所帮助,以便您可以轻松地在编辑过程中看到更改(来源:VIM :set list! 作为 .vimrc 中的切换):

It might be helpful to add a toggle to it so you can see the changes mid editing easily (source: VIM :set list! as a toggle in .vimrc):

noremap <F5> :set list!<CR>
inoremap <F5> <C-o>:set list!<CR>
cnoremap <F5> <C-c>:set list!<CR>

这篇关于使 Vim 将所有空格显示为字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆