Tip #235: Toggle highlight word under cursor, to find cursor.
tip karma |
Rating 15/11, Viewed by 1038
|
created: |
|
April 11, 2002 7:27 |
|
complexity: |
|
basic |
author: |
|
HughSasse |
|
as of Vim: |
|
6.0 |
When the screen has scrolled such as during a search, it may be difficult to find the cursor. :help %# explains the pattern one can use to highlight the word around the cursor, which gives a bigger target to look for on the screen. I have this in my .vimrc:
function VIMRCWhere()
if !exists("s:highlightcursor")
match Todo /\k*\%#\k*/
let s:highlightcursor=1
else
match None
unlet s:highlightcursor
endif
endfunction
map <C-K> :call VIMRCWhere()<CR>
This means that in "normal" mode ctrl-k will toggle the highlight. Todo is a hightlight group whch is particularly easy to see.
For further information see ":help s:", ":help match", ":help exists()" and ":help funtion".
<<Vi(M) Command Line tips & tricks |
Menu for inserting special characters >>
Additional Notes
|