Browse files

Use invhlsearch instead of nohlsearch

This command toggles the highlight state, allowing the user to turn it off and
on as desired without it automatically turning back on.

I found it very annoying that some random command would set the search pattern
to something common like `\s\+` and suddenly my entire Vim session would be
highlighted. `<leader>/` turned if off but any kind of search related motion (or
running the command again, for example) would turn it back on again.

If the user turns off search highlighting, they probably don't want it to
immediately turn back on. If they do, it's as easy as `<leader>/` again.
  • Loading branch information...
1 parent 0834355 commit a8d74e97b13ee2362381c645567506e66295503a @johntyree committed Dec 22, 2012
Showing with 2 additions and 2 deletions.
  1. +2 −2 .vimrc
4 .vimrc
@@ -241,8 +241,8 @@
nmap <leader>f8 :set foldlevel=8<CR>
nmap <leader>f9 :set foldlevel=9<CR>
- "clearing highlighted search
- nmap <silent> <leader>/ :nohlsearch<CR>
+ " Toggle search highlighting
+ nmap <silent> <leader>/ :set invhlsearch<CR>
" Shortcuts
" Change Working Directory to that of the current file

0 comments on commit a8d74e9

Please sign in to comment.