VIM:如何在不使用非文本颜色元素的情况下更改 Showbreak 高亮颜色
我注意到“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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为您不会突出显示与 EOL 角色不同的内容,至少我不知道有什么方法可以做到这一点。
对于第二部分,我可以提供帮助。通过以下设置,我能够让“↳”显示在我的行号列中:
请注意,
↳
后面有一个空格。这一切都很好,直到你有 >文件中有 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:
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.
:help hl-NonText
非常清楚地表明,'showbreak'
字符串和其他非文本字符串不能使用不同的颜色,其中eol 是成员(请参阅
:help 'listchars'
):如果您愿意接受此限制 (@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 whicheol
is a member (see:help 'listchars'
):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 theNonText
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.