Thursday, December 24, 2009

cursorline/cursorcolumn highlighting

When I present source code, it is easier if I use cursorline/
cursorcolumn highlighting to direct eyes to the relevant section.

I wanted a function key to turn on and off the highlighting, but did
not want to dedicate more than one of those valuable resources. So...
in this example F7 cycles thru the cursorline and cursorcolumn
highlighting.

For Vim versions older that 7, it only moves the line to the center of
the screen.

I am somewhat new to Vim scripting, please comment or suggest
improvements.

" toggle cursorline/cursorcolumn or center line
nmap <F7> zz
if version >= 700 " NONE turns off underlining
highlight CursorLine NONE ctermbg=Yellow
highlight CursorColumn NONE ctermbg=Yellow
let s:lico=0
function LiCo()
let s:lico=s:lico>2 ?0 :s:lico+1
let &cursorline=s:lico % 2
let &cursorcolumn=s:lico / 2
endfun
nmap <silent> <F7> :call LiCo()<cr>
endif
imap <F7> <c-o><F7>
vmap <F7> <c-c><F7>gv

--
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php

No comments: