[SOLVED] How to highlight the current line number in vim

Write tutorials here
There are more tutorials here http://community.linuxmint.com/tutorial/welcome
Forum rules
Please don't add support questions to tutorials,start your own thread in the appropriate sub-forum instead. Before you post please read this
flyingrhino
Level 3
Level 3
Posts: 113
Joined: Sat Apr 04, 2015 8:55 pm

[SOLVED] How to highlight the current line number in vim

Postby flyingrhino » Tue Oct 24, 2017 8:30 pm

Yes sure the 'set cursorline' command underlines the current line, but it is distracting. Not to mention that it hides underscores and is ugly.

I found a better solution - that is - if you display line numbers.
Here is a basic vimrc.local I use.
Notice the 'set number' which enables displaying line numbers on the left.
Then there's the code block in the middle 'Enables cursor line position tracking' that does the current line number highlighting.

Code: Select all

syntax on
colorscheme default
set bg=dark
set tabstop=4
set autoindent
set nobackup
set number
set showcmd
set showmatch
set scrolloff=5

" Enables cursor line position tracking:
set cursorline
" Removes the underline causes by enabling cursorline:
highlight clear CursorLine
" Sets the line numbering to red background:
highlight CursorLineNR ctermbg=red   

" These settings highlight a vertical cursor column:
"set cursorcolumn
"highlight CursorColumn ctermfg=White ctermbg=Yellow cterm=bold guifg=white guibg=yellow gui=bold
"highlight CursorColumn ctermfg=Black ctermbg=Yellow cterm=bold guifg=Black guibg=yellow gui=NONE


Return to “Tutorials”