vim 中高亮显示当前行号
有没有办法在 vim 中仅突出显示当前行号(在左栏),而不突出显示当前行的背景?理想情况下,我希望将当前行号设为粗体。
Is there a way to highlight only the current line number (in the left hand coloumn) in vim, without highlighting the background of the current line? Ideally, I would Like to make the current line number bold.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
有两组确定
&cursorline
选项处于活动状态时显示的行的突出显示:CursorLine
和CursorLineNR
。第一个用于突出显示整行,第二个用于突出显示行号。因此,要实现您想要的效果,您必须清除
CursorLine
的突出显示:只需hiclear CursorLine
在任何:colorscheme
之后并且设置背景=
调用。如果您的颜色方案中未设置
CursorLineNR
,请设置它的突出显示:(最好检查它是否已经在颜色方案中设置,也许在这种情况下看起来会更好)。
当然,您可以将这两个自动命令加入其中。
CursorLineNR
是最近在7.3.488
版本中添加的。There are two groups that determine highlighting of line displayed when
&cursorline
option is active:CursorLine
andCursorLineNR
. First is used to highlight the whole line, second for the line number. So to achieve what you want you mustClear the highlighting of
CursorLine
: justhi clear CursorLine
after any:colorscheme
andset background=
call.Set the highlighting of
CursorLineNR
if it is not set in your colorscheme:(better to check whether it is already set in the colorscheme, maybe it will look better in that case).
You can join both autocommands in one of course.
CursorLineNR
has been added relatively recently around version7.3.488
.你想看看
,也许甚至/也
You want to look at
and perhaps even/also
这对我有用:
设置配色方案后,我只是在 .vimrc 中使用它。当然,您也可以设置特定的背景颜色,但将它们全部设置为“无”只会突出显示行号(即使其更亮)。
我想你可以只使用
:hi CursorLine cterm=NONE
但我只是想确保一切都透明(包括 gvim)。通过 CursorLineNR,我可以设置突出显示数字的前景色和背景色。
我写这篇文章只是因为对我来说它无需任何自动命令即可工作,并且可能是大多数人所需要的。
This is what worked for me:
I'm just using this in my .vimrc after having set the color scheme. Of course you could also set a specific background color but setting all of them to NONE just highlights the line number (i.e. makes it brighter).
I guess you could just use
:hi CursorLine cterm=NONE
but I just wanted to make sure I'm making everything transparent (gvim included).With
CursorLineNR
I was then able to set the foreground and background colors of the highlighted number.I'm only writing this because for me it worked without any autocommands and it may be what most people require.
您可以设置光标线以仅突出显示数字
并覆盖你的颜色方案 使用 autocmd
所以,以下工作:
You can set cursorline to highlight only the numbers
And to override your colorscheme use autocmd
So, the following works:
这对我来说可以突出显示行号而不是行的其余部分:
highlight CursorLineNr cterm=NONE ctermbg=15 ctermfg=8 gui=NONE guibg=#ffffff guifg=#d70000
This worked for me to highlight the line number and not the rest of the line:
highlight CursorLineNr cterm=NONE ctermbg=15 ctermfg=8 gui=NONE guibg=#ffffff guifg=#d70000
highlight-groups 的帮助没有提到专有的“当前的数量” line”语法组,因此官方答案可能是否。
您可能需要查看 cursorline 选项,该选项突出显示整行,如果有帮助的话。
The help for highlight-groups does not mention an exclusive "number of current line" syntax group, so the official answer might be no.
You may want to take a look in the cursorline option which highlights the entire line, if it helps.