" word-under-cursor-highlight.vim - Highlight the word under the cursor " vim: set ft=vim sw=8 noet " " Author: Bart Trojanowski " Date: 2010/06/13 " Version: 0 " " inspired by http://www.nrtm.de/index.php/2010/06/13/a-little-more-eclipse-in-vim/ highlight WordUnderCursorHighlight ctermfg=none ctermbg=none cterm=underline "highlight WordUnderCursorHighlight ctermfg=none ctermbg=DarkBlue cterm=none augroup HighlightWordUnderCursorGroup autocmd! autocmd CursorMoved * call HighlightWordUnderCursor() autocmd CursorMovedI * call HighlightWordUnderCursor() augroup END function! HighlightWordUnderCursor() let s:word = '' let s:ch = getline('.')[col('.')-1] if s:ch =~ '[a-z0-9A-Z_]' let s:word = expand('') execute 'match WordUnderCursorHighlight /\<'.s:word.'\>/' else match none endif echo s:ch . ' ' . s:word endfunction