自定义vim标签栏的颜色
如何修改 vim 标签栏的颜色?
我尝试过使用
:hi TabLineFill ctermbg=N
它确实将选项卡栏背景的颜色更改为“N”表示的颜色,但这就是我从谷歌搜索中收集到的全部内容。我查看了 :help cterm-colors
,但我并没有从中获得更多的理解。
我是否能够使用此突出显示功能来更改活动选项卡的前景和背景以及非活动选项卡的前景和背景的颜色?如果是这样,我将如何去做这件事?
How would one go about modifying the colour of vim's tab bar?
I have tried using
:hi TabLineFill ctermbg=N
which does change the colour of the tab bar's background to the colour that 'N' signifies, but this is all I have managed to glean from Googling. I had a look at :help cterm-colors
, but I did not gain much more of an understanding from it.
Would I be able to use this highlight facility to change the colour of an active tab's foreground and background, and an inactive tab's foreground and background? If so, how would I go about doing this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
例如,您可以执行以下操作:
此行影响每个选项卡的窗口计数器:
选择花哨的颜色来突出显示每个项目的更改内容。
我发现在使用 时查看
$VIMRUNTIME/colors/*.vim
确实很有帮助突出显示。请注意,这些会更改在控制台中运行的 Vim 的颜色。如果您想更改 GVim 的颜色,则需要使用
guibg
、guifg
等。例如:You can do the following, for example:
This line affects the window counter per tab:
Garish colours chosen to highlight what each of the items changes.
I find that looking at
$VIMRUNTIME/colors/*.vim
really helps when playing with highlighting.Note that these change the colours for Vim running in a console. If you want to change the colours for GVim, you need to use
guibg
,guifg
, et cetera. For example:是的,你会的。
标签行中有三个项目可以根据您的喜好进行自定义:TabLine、TabLineSel 和 TabLineFill。
TabLineSel - 是当前(可以这么说)活动选项卡标签。
TabLine - 是当前未激活的标签。
TabLineFill - 是选项卡行的剩余部分,其中没有标签(背景)。
您可以按照通常的方式修改所有三个。
Yes, you would.
There are three items in the tab line that can be customized to your liking: TabLine, TabLineSel and TabLineFill.
TabLineSel - is the current (so to say) active tab label.
TabLine - are the labels which are not currently active.
TabLineFill - is the remaining of the tabline where there is no labels (background).
You modify all three of them in the usual way.
'tabline' 选项指定带有标签页标签的行的外观。
仅当没有 GUI 选项卡行时才使用它。
您可以使用“showtabline”选项来指定何时需要该行
要出现的选项卡页标签:当存在多个选项卡页时从不出现或
总是。
选项卡页行的突出显示通过组 TabLine 设置
TabLineSel 和 TabLineFill。 |hl-TabLine| |hl-TabLineSel| |hl-TabLineFill|
对于具有修改窗口的选项卡页,将显示“+”。数量
标签页中的窗口也会显示。因此“3+”意味着三个窗口和其中一个
他们有一个修改过的缓冲区。
“tabline”选项允许您定义选项卡页面的首选方式
标签。这并不容易,因此这里将给出一个例子。
有关基础知识,请参阅“状态行”选项。相同的项目可用于
“表格线”选项。此外,|tabpagebuflist()|、|tabpagenr()|和
|tabpagewinnr()|功能很有用。
由于选项卡标签的数量会有所不同,因此您需要使用表达式
整个选项。类似于:>
:set tabline=%!MyTabLine()
然后定义 MyTabLine() 函数来列出所有选项卡页标签。一个
方便的方法是将其分成两部分:首先浏览所有选项卡
页面并为其定义标签。然后获取每个标签页的标签。 >
现在为每个选项卡页调用 MyTabLabel() 函数来获取其标签。 >
这只是一个简单的示例,它会产生一个选项卡页行
类似于默认值,但没有添加 + 来表示修改后的缓冲区或
截断名称。您将需要减少标签的宽度
当空间不足时,这是一个聪明的方法。检查“列”选项
可用空间。
The 'tabline' option specifies what the line with tab pages labels looks like.
It is only used when there is no GUI tab line.
You can use the 'showtabline' option to specify when you want the line with
tab page labels to appear: never, when there is more than one tab page or
always.
The highlighting of the tab pages line is set with the groups TabLine
TabLineSel and TabLineFill. |hl-TabLine| |hl-TabLineSel| |hl-TabLineFill|
A "+" will be shown for a tab page that has a modified window. The number of
windows in a tabpage is also shown. Thus "3+" means three windows and one of
them has a modified buffer.
The 'tabline' option allows you to define your preferred way to tab pages
labels. This isn't easy, thus an example will be given here.
For basics see the 'statusline' option. The same items can be used in the
'tabline' option. Additionally, the |tabpagebuflist()|, |tabpagenr()| and
|tabpagewinnr()| functions are useful.
Since the number of tab labels will vary, you need to use an expression for
the whole option. Something like: >
:set tabline=%!MyTabLine()
Then define the MyTabLine() function to list all the tab pages labels. A
convenient method is to split it in two parts: First go over all the tab
pages and define labels for them. Then get the label for each tab page. >
Now the MyTabLabel() function is called for each tab page to get its label. >
This is just a simplistic example that results in a tab pages line that
resembles the default, but without adding a + for a modified buffer or
truncating the names. You will want to reduce the width of labels in a
clever way when there is not enough room. Check the 'columns' option for the
space available.
您可以使用 自动命令组 使@Johnsyweb 的出色答案中的更改永久生效。将以下内容放入
~/.vimrc
中:您可以尝试更改 颜色 任何你喜欢的东西。
You can use autocommand groups to make the changes from @Johnsyweb's excellent answer permanent. Place the following in your
~/.vimrc
:You can experiment with changing the colors to whatever you like.