VIM:如何在不使用非文本颜色元素的情况下更改 Showbreak 高亮颜色

发布于 2024-11-02 21:24:14 字数 234 浏览 3 评论 0原文

我注意到“showbreak”符号通过突出显示“NonText”颜色元素突出显示。非文本也用于 EOL 字符。
我想保留 EOL 字符的突出显示颜色,但想更改演出符号的突出显示颜色,这可能吗?

另一个问题是我的表演符号没有显示。 我想使用这个符号“↳”并将其放入行号列中(使用 set cpoptions+=n)。我不知道如何显示该符号以及如何在演出中断符号之后(文本和符号之间)放置一个空格。

有人可以帮助我吗?

I noted that the 'showbreak' symbol is highlighted with the highlight "NonText" color-element. NonText is also used for the EOL Characters.
I would like to keep the highlight-color for the EOL characters but want to change it for the showbreak symbol is that possible?

Another problem is that my showbreak symbol is not displayed.
I would like to use this symbol "↳" and put it in the linenumbers column (using set cpoptions+=n). I can't find out how to display the symbol and how to put a space after the showbreak symbol (between the text and the symbol).

Can anyone help me?

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

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

发布评论

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

评论(2

夢归不見 2024-11-09 21:24:14

我认为您不会突出显示与 EOL 角色不同的内容,至少我不知道有什么方法可以做到这一点。

对于第二部分,我可以提供帮助。通过以下设置,我能够让“↳”显示在我的行号列中:

let &showbreak = '↳ '
set wrap
set cpo=n

请注意, 后面有一个空格。这一切都很好,直到你有 >文件中有 9 行。如果您希望它与数字列的最后一个字符对齐,而不管行数如何,我不确定您需要做什么。

编辑:我最近编写了一个 概念验证函数 对于 IRC 上的某人,突出显示已用不同突出显示组包裹的行中的第一个字符。它尚未经过太多测试,但似乎有效。不完全是您正在寻找的内容,但也许值得一看。

I don't think you're going to get highlighting to be different than the EOL character, at least I am not aware of a way to do that.

For the second part I can help with. I was able to get "↳ " to show up in my line number column with the following settings:

let &showbreak = '↳ '
set wrap
set cpo=n

Note that there is a space after the . This lines up nice until you have > 9 lines in the file. If you wanted it to line up with the last character of the number column regardless of the number of lines I'm not sure what you're going to have to do.

Edit: I've recently written a proof-of-concept function for someone on IRC that highlights the first character on a line that has been wrapped with a different highlight group. It hasn't been tested much but it seems to work. Not exactly what you're looking for but maybe it's worth a look.

单挑你×的.吻 2024-11-09 21:24:14

:help hl-NonText 非常清楚地表明,'showbreak' 字符串和其他非文本字符串不能使用不同的颜色,其中 eol 是成员(请参阅 :help 'listchars'):

非文本

窗口末尾的“~”和“@”,来自“showbreak”的字符和
文本中并不真正存在的其他字符(例如“>”
当双宽字符不适合末尾时显示
线)。

如果您愿意接受此限制 (@elliottcable) 嗨! link NonText LineNr 会将 'showbreak' 字符串与行号颜色进行匹配。

如果你真的想变得聪明,作为妥协,你可以创建一个映射或命令来在 ':set list'':set nolist' 之间切换,这也会调整同时进行NonText highlight 设置。

如果你使用 :setrelativenumber (在 vim 7.3 中添加), :set showbreak=↳\ \ \ 会可靠地保持你的 'showbreak' 整齐排列,因为当您浏览文件时数字宽度不会改变。 (这是除了 @Randy Morris 在他的回答中提到的 :set cpo+=n:set wrap 之外的。)

您肯定需要 UTF-8 作为 字符,因为它不会出现在其他编码中。我强烈建议您仔细记录您的编码问题,详细说明如何重现它们以及您的操作系统、版本和 vim 的 :version 输出,并将它们作为单独的问题发布。 UTF-8 应该帮助您处理多种语言而不是成为障碍。

:help hl-NonText makes it pretty clear that you cannot have different colors for the 'showbreak' string and other non-text strings, of which eol is a member (see :help 'listchars'):

NonText

'~' and '@' at the end of the window, characters from 'showbreak' and
other characters that do not really exist in the text (e.g., ">"
displayed when a double-wide character doesn't fit at the end of the
line).

If you're willing to accept this limitation (@elliottcable) hi! link NonText LineNr will match the 'showbreak' string to the line number colors.

If you really wanted to get clever, as a compromise you could create a mapping or command to toggle between ':set list' and ':set nolist' that would also adjust the NonText highlight setting simultaneously.

If you use :set relativenumber (added in vim 7.3), :set showbreak=↳\ \ \ will reliably keep your 'showbreak' neatly lined up since the number width will not change as you navigate through the file. (This in addition to the :set cpo+=n and :set wrap @Randy Morris mentioned in his answer.)

You'll definitely need UTF-8 for the character, since it does not appear in other encodings. I'd strongly recommend you carefully document your encoding problems, with details about how to reproduce them along with your OS, its version, and the :version output of vim, and post them as separate questions. UTF-8 should be helping you wrangle multiple languages rather than being an impediment.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文