如何与背景颜色一起显示尾随空间?

发布于 2025-02-10 09:09:30 字数 241 浏览 2 评论 0原文

在vim中,我该如何在线条结束之前以不同的背景颜色结束前显示后线空间/选项卡?这可能吗?

因此,这样的事情:

“背景颜色的尾线”

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:

Trailing lines in background color

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

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

发布评论

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

评论(2

黯然#的苍凉 2025-02-17 09:09:30

我不确定背景,但是要使尾随空间可见,您可以

set list listchars=trail:x

x的位置使用,是每个尾随空间所显示的字符。

这意味着,如果您使用“完整块”字符(请参阅在这里),您可以获得漂亮您想要的结果很多。

除了我不知道如何控制其颜色。

I'm not sure about the background, but to make trailing spaces visible, you can use

set list listchars=trail:x

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.
enter image description here
Except that I have no idea how to control its color.

记忆之渊 2025-02-17 09:09:30

这是一个快速且肮脏的解决方案:

augroup TrailingSpaces
    autocmd!
    autocmd winEnter,BufEnter * call clearmatches() | call matchadd('ColorColumn', '\s\+

注释:

  • 自动仪:help winenter and :help bufenter 。这不是最佳的,但对于处理某些角案件所必需。
  • :help matchadd()允许我们在当前窗口中添加任何数量的火柴。
  • :help clearMatches()将清除使用 matchadd()的所有内容,包括插件中的内容。再次,这不是一种最佳方法,您可能会遇到副作用。
, 100) augroup END

注释:

  • 自动仪:help winenter and :help bufenter。这不是最佳的,但对于处理某些角案件所必需。
  • :help matchadd()允许我们在当前窗口中添加任何数量的火柴。
  • :help clearMatches()将清除使用matchadd()的所有内容,包括插件中的内容。再次,这不是一种最佳方法,您可能会遇到副作用。

trailing spaces

Here is a quick and dirty solution:

augroup TrailingSpaces
    autocmd!
    autocmd winEnter,BufEnter * call clearmatches() | call matchadd('ColorColumn', '\s\+

Comments:

  • The autocommand is triggered on :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 with matchadd(), including stuff from plugins. Once again, this is not an optimal approach and you may encounter side-effects.
, 100) augroup END

Comments:

  • The autocommand is triggered on :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 with matchadd(), including stuff from plugins. Once again, this is not an optimal approach and you may encounter side-effects.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文