在vim中突出显示当前行号 [英] Highlighting the current line number in 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.
推荐答案
当 &cursorline
选项处于活动状态时,有两个组决定了显示行的突出显示:CursorLine
和 CursorLineNR
.第一个用于突出显示整行,第二个用于行号.所以要达到你想要的,你必须
There are two groups that determine highlighting of line displayed when &cursorline
option is active: CursorLine
and CursorLineNR
. First is used to highlight the whole line, second for the line number. So to achieve what you want you must
清除
CursorLine
的高亮:只需hi clear CursorLine
在任何:colorscheme
和设置背景之后=
调用.
Clear the highlighting of
CursorLine
: justhi clear CursorLine
after any:colorscheme
andset background=
call.
hi clear CursorLine
augroup CLClear
autocmd! ColorScheme * hi clear CursorLine
augroup END
如果您的配色方案中没有设置 CursorLineNR
的突出显示:
hi CursorLineNR cterm=bold
augroup CLNRSet
autocmd! ColorScheme * hi CursorLineNR cterm=bold
augroup END
(最好检查一下是否已经在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
是最近在 7.3.488
版本附近添加的.
CursorLineNR
has been added relatively recently around version 7.3.488
.
这篇关于在vim中突出显示当前行号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!