如何与背景颜色一起显示尾随空间?
How can I in VIM show the trailing spaces/tab before the line end with a different background color? Is this possible?
So something like this:
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不确定背景,但是要使尾随空间可见,您可以
在
x
的位置使用,是每个尾随空间所显示的字符。这意味着,如果您使用“完整块”字符(请参阅在这里),您可以获得漂亮您想要的结果很多。

除了我不知道如何控制其颜色。
I'm not sure about the background, but to make trailing spaces visible, you can use
where
x
is the character shown in place of each one of the trailing spaces.This means that if you use a "full block" character (see here), you obtain pretty much the result you want.

Except that I have no idea how to control its color.
这是一个快速且肮脏的解决方案:
注释:
:help winenter
and:help bufenter
。这不是最佳的,但对于处理某些角案件所必需。:help matchadd()
允许我们在当前窗口中添加任何数量的火柴。:help clearMatches()
将清除使用matchadd()
的所有内容,包括插件中的内容。再次,这不是一种最佳方法,您可能会遇到副作用。Here is a quick and dirty solution:
Comments:
:help winEnter
and:help bufEnter
. This is not optimal but necessary to handle some corner cases.:help matchadd()
allows us to add any number of matches in the current window.:help clearmatches()
will clear everything that was added withmatchadd()
, including stuff from plugins. Once again, this is not an optimal approach and you may encounter side-effects.