obcat / vim-hitspop

πŸ’¬ Popup the number of search results

Home Page:https://zenn.dev/obcat/articles/4ef6822de53b643bbd01

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

vim-hitspop

Popup the number of search results.

hitspop eyecatch

Installation

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.

Usage

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.

Tips

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).

Customization

You can customize some features.

Position

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'

popup at botright

You can also specify other positions. Please see help file for more information.

Highlight

The popup color can be changed setting the following highlight groups:

  • hitspopNormal (default: links to Pmenu)
  • hitspopErrorMsg (default: links to Pmenu)

Example:

errormsg highlighting

highlight link hitspopErrorMsg ErrorMsg

πŸ“ I use iceberg.vim for color scheme.

License

MIT License.

About

πŸ’¬ Popup the number of search results

https://zenn.dev/obcat/articles/4ef6822de53b643bbd01

License:MIT License


Languages

Language:Vim Script 100.0%