Skip to content

Instantly share code, notes, and snippets.

@adnils
Last active August 29, 2015 14:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adnils/9bff17c8d5fbd3486a8e to your computer and use it in GitHub Desktop.
Save adnils/9bff17c8d5fbd3486a8e to your computer and use it in GitHub Desktop.
highlight occurrences of word under cursor on spacebar
let g:highlighting = 0
function! Highlighting()
if g:highlighting == 1 && @/ =~ '^\\<'.expand('<cword>').'\\>$'
let g:highlighting = 0
return ":silent nohlsearch\<CR>"
endif
let @/ = '\<'.expand('<cword>').'\>'
let g:highlighting = 1
return ":silent set hlsearch\<CR>"
endfunction
nnoremap <silent> <expr> <Space> Highlighting()
noremap O O<Esc>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment