diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..0d48cca --- /dev/null +++ b/LICENSE @@ -0,0 +1,22 @@ +The MIT License (MIT) + +Copyright (c) 2016 Romain Lafourcade + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + diff --git a/README.md b/README.md new file mode 100644 index 0000000..295e70a --- /dev/null +++ b/README.md @@ -0,0 +1,7 @@ +# vim-cool + +Vim-cool disables search highlighting when you are done searching and re-enables it when you search. + +Vim-cool re-enables search highlighting when the cursor is on a word that matches the last search pattern. + +Vim-cool is cool. diff --git a/plugin/cool.vim b/plugin/cool.vim new file mode 100644 index 0000000..1db8018 --- /dev/null +++ b/plugin/cool.vim @@ -0,0 +1,48 @@ +" vim-cool - Disable hlsearch when you are done searching. +" Maintainer: romainl +" Version: 0.0.1 +" License: MIT License +" Location: plugin/cool.vim +" Website: https://github.com/romainl/vim-cool + +if exists("g:loaded_cool") || v:version < 703 || &compatible + finish +endif +let g:loaded_cool = 1 + +let s:save_cpo = &cpo +set cpo&vim + +if &hlsearch + nnoremap / :silent set hlsearch/ + nnoremap ? :silent set hlsearch? + + nnoremap n n:set hlsearch + nnoremap N N:set hlsearch + + nnoremap * *:set hlsearch + nnoremap # #:set hlsearch + + cnoremap Cool() + + autocmd! CursorMoved * silent call Cooler() + + function! s:Cool() + let cmd = getcmdtype() + if cmd == "/" || cmd == "?" + return "\:set hlsearch\" + else + return "\" + endif + endfunction + + function! s:Cooler() + if expand("") =~ @/ + set hlsearch + else + set nohlsearch + endif + endfunction +endif + +let &cpo = s:save_cpo