突出显示vim中的当前行号

cg4*_*33n 34 vim syntax-highlighting

有没有办法突出显示vim中的当前行号(左手coloumn),而不突出显示当前行的背景?理想情况下,我想将当前行号加粗.

ZyX*_*ZyX 34

&cursorline选项处于活动状态时,有两组确定显示的行的突出显示:CursorLineCursorLineNR.第一个用于突出显示整行,第二个用于行号.所以要实现你想要的一切

  1. 清除突出显示CursorLine:hi clear CursorLine 在任何:colorschemeset background=呼叫之后.

    hi clear CursorLine
    augroup CLClear
        autocmd! ColorScheme * hi clear CursorLine
    augroup END
    
    Run Code Online (Sandbox Code Playgroud)
  2. CursorLineNR如果未在colorscheme中设置,请设置突出显示:

    hi CursorLineNR cterm=bold
    augroup CLNRSet
        autocmd! ColorScheme * hi CursorLineNR cterm=bold
    augroup END
    
    Run Code Online (Sandbox Code Playgroud)

    (更好地检查它是否已经设置在colorscheme中,在这种情况下它可能看起来更好).

您可以在一个中加入两个自动命令.

CursorLineNR已经相对最近添加版本7.3.488.


seh*_*ehe 14

你想看看

:se cursorline
Run Code Online (Sandbox Code Playgroud)

甚至/也可能

:se cursorcolumn
Run Code Online (Sandbox Code Playgroud)

  • @Pétur和任何其他选项一样,所以`:se cul!`或者例如`:se nocursorline` (3认同)

Ale*_*anu 11

这对我有用:

highlight CursorLine cterm=NONE ctermbg=NONE ctermfg=NONE guibg=NONE guifg=NONE
set cursorline
Run Code Online (Sandbox Code Playgroud)

在设置颜色方案后,我只是在我的.vimrc中使用它.当然,您也可以设置特定的背景颜色,但将它们全部设置为NONE只会突出显示行号(即使其更亮).

我想你可以使用,:hi CursorLine cterm=NONE但我只是想确保我让一切都透明(包括gvim).

随着CursorLineNR当时我能够设置高亮数量的前景色和背景色.

我只是写这个,因为对我而言,它没有任何自动命令,它可能是大多数人所需要的.


Hri*_*tik 9

您可以设置光标线以仅突出显示数字

'cursorlineopt' 'culopt' string (default: "number,line")                        
                        local to window                                         
                        {not available when compiled without the +syntax        
                        feature}                                                
        Comma separated list of settings for how 'cursorline' is displayed.     
        Valid values:                                                           
        "line"          Highlight the text line of the cursor with              
                        CursorLine hl-CursorLine.                               
        "screenline"    Highlight only the screen line of the cursor with       
                        CursorLine hl-CursorLine.                               
        "number"        Highlight the line number of the cursor with            
                        CursorLineNr hl-CursorLineNr.             
Run Code Online (Sandbox Code Playgroud)

使用 autocmd覆盖您的颜色方案

因此,以下工作:

set cursorline
set cursorlineopt=number
autocmd ColorScheme * highlight CursorLineNr cterm=bold term=bold gui=bold
Run Code Online (Sandbox Code Playgroud)


小智 5

这对我来说可以突出显示行号而不是行的其余部分:

highlight CursorLineNr cterm=NONE ctermbg=15 ctermfg=8 gui=NONE guibg=#ffffff guifg=#d70000