Highlighting the current line number in vim

前端 未结 6 738
忘了有多久
忘了有多久 2021-01-30 20:47

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

6条回答
  •  误落风尘
    2021-01-30 21:21

    You can set cursorline to highlight only the numbers

    '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.             
    

    And to override your colorscheme use autocmd

    So, the following works:

    set cursorline
    set cursorlineopt=number
    autocmd ColorScheme * highlight CursorLineNr cterm=bold term=bold gui=bold
    

提交回复
热议问题