Popup the number of search results.
Requires Vim 8.2.0896 or later. Neovim is not supported.
If you use vim-plug, then add the following line to your vimrc:
Plug 'obcat/vim-hitspop'
You can use any other plugin manager.
The hlsearch
option must be turned on for this plugin to work:
set hlsearch
This is all you need to set up. If you run a search command like /foo
, a popup
will appear and show you the number of search results like foo 3 of 7
.
When you stop highlighting, the popup will be closed automatically.
Highlighting can be stopped with the nohlsearch
command. To run this command
quickly, you may want to set up the following map:
nnoremap <silent> <ESC><ESC> :<C-u>nohlsearch<CR>
You can also use the nohlsearch feature of is.vim plugin to stop highlighting automatically. Please see the link for details.
To be precise, popup will be closed when one of the following occurs after stopping highlighting:
- The cursor was moved.
- The time specified with
updatetime
option has elapsed.
The default value of updatetime
is 4000
, i.e. 4 seconds. If you want to
close the popup as soon as possible after stopping highlighting, reduce the
value of this option. I suggest around 100ms:
set updatetime=100
Note that updatetime
also controls the delay before Vim writes its swap file
(see :h updatetime
).
You can customize some features.
By default, popup is displayed at top right corner of current window. If you want to display the popup, for example, at bottom left corner of current window, use this:
let g:hitspop_line = 'winbot'
let g:hitspop_column = 'winright'
You can also specify other positions. Please see help file for more information.
The popup color can be changed setting the following highlight groups:
hitspopNormal
(default: links toPmenu
)hitspopErrorMsg
(default: links toPmenu
)
Example:
highlight link hitspopErrorMsg ErrorMsg
📝 I use iceberg.vim for color scheme.
MIT License.