Highlight the Current Line

I've used cursorline for so long I can't even remember when I added it to my .vimrc. It highlights the current line so you can see the cursor more easily. The highlight is restricted to the current buffer, so it's easy to see in a collection of split windows as well.

The exact settings I use for my dark background theme are as follows:

set cursorline
hi cursorline cterm=none term=none
autocmd WinEnter * setlocal cursorline
autocmd WinLeave * setlocal nocursorline
highlight CursorLine guibg=#303000 ctermbg=234

This also only highlights the line in the current window, which I found works well in GUI Vim, although I don't usually use gVim/MacVim.

A reader recently sent in Conoline.vim which is a plugin that does all of this and more. It changes the highlight based on the current mode, and it's easy to theme and supports both light and dark colour schemes.

The documentation explains how to turn it on, off, and how to change each colour. It seems like a better way to deal with highlights if you like switching themes.

blog comments powered by Disqus