├── .gitignore ├── README.md ├── doc └── searchlight.txt ├── example.gif └── plugin └── searchlight.vim /.gitignore: -------------------------------------------------------------------------------- 1 | doc/tags 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # vim-searchlight 2 | 3 | Searchlight = Search + Highlight 4 | 5 | Vim-searchlight highlights Vim's current search match. 6 | 7 | ![alt text](/example.gif) 8 | 9 | ## CurSearch 10 | 11 | Vim 8.2.4724+ supports `CurSearch`, as well as NeoVim 0.10+. In this case the `Searchlight` highlight group is linked to `CurSearch` and the rest of the plugin is disabled. 12 | 13 | ## Requirements 14 | 15 | Searchlight requires `'hlsearch'` to be active and Vim 8+ with timer support. It is tested on Vim 8.1. 16 | 17 | 18 | ## Experimental 19 | 20 | Searchlight is an experiment. Your mileage my vary. Might not work with other plugins or your `vimrc`. 21 | 22 | ## Installation 23 | 24 | Follow your favorite plugin/runtimepath manager's instructions. 25 | 26 | If you choose manual installation, use Vim's packages. Clone into one of the following directories: 27 | 28 | $HOME/.vim/pack/bundle/start/ on Unix-like systems 29 | $HOME\vimfiles\pack\bundle\start\ on Windows 30 | 31 | ## Commands 32 | 33 | Use `:Searchlight` to enable and `:Searchlight!` to disable. 34 | 35 | ## Customization 36 | 37 | Searchlight uses the `Searchlight` highlight group. It defaults to `ErrorMsg`. Change by doing: 38 | 39 | highlight link Searchlight Incsearch 40 | 41 | Searchlight's highlighting can be triggered manually via `:1Searchlight`. This might be required for some mappings or plugin compatibility. 42 | 43 | Searchlight is activated by default on startup. To prevent this set `g:searchlight_disable_on_startup`. e.g. 44 | 45 | let g:searchlight_disable_on_startup = 1 46 | 47 | ## Background 48 | 49 | This is an experiment to implement current search highlighting without any mappings. Thank-you to both [vim-searchhi](https://github.com/qxxxb/vim-searchhi) & [vim-searchant](https://github.com/timakro/vim-searchant) which inspired this plugin. 50 | 51 | ## Known Issues 52 | 53 | When using any search command like: `*`, `#`, etc at the beginning of a match and it is the only match and therefore will not cause the cursor to move, will not trigger searchlight. 54 | 55 | One solution would be to trigger an update with mappings like so: 56 | 57 | nnoremap * *:1Searchlight 58 | nnoremap # #:1Searchlight 59 | 60 | However, this goes against the goal of having no mappings. Sad panda 61 | -------------------------------------------------------------------------------- /doc/searchlight.txt: -------------------------------------------------------------------------------- 1 | *searchlight.txt* Highlight the current search match 2 | 3 | Author: Peter Rincker *searchlight-author* 4 | License: Same terms as Vim itself (see |license|) 5 | 6 | This plugin is only available if 'compatible' is not set. 7 | 8 | ============================================================================== 9 | *searchlight* 10 | Searchlight = Search + Highlight 11 | Highlights the current search match. 12 | 13 | Vim 8.2.4724+ supports |hl-CurSearch|, as well as NeoVim 0.10+. In this case 14 | |hl-Searchlight| is a highlight link to |hl-CurSearch|. 15 | 16 | 1. Commands |searchlight-commands| 17 | 2. Requirements |searchlight-requirements| 18 | 3. Customization |searchlight-customization| 19 | 4. Issues |searchlight-issues| 20 | 21 | ============================================================================== 22 | 1. Searchlight commands *searchlight-commands* 23 | 24 | *:Searchlight* 25 | :Searchlight Enable Searchlight 26 | :Searchlight! Disable Searchlight 27 | 28 | ============================================================================== 29 | 2. Searchlight requirements *searchlight-requirements* 30 | 31 | Searchlight requires |'hlsearch'| to be active and |+timer| support. > 32 | 33 | set hlsearch 34 | < 35 | 36 | ============================================================================== 37 | 3. Searchlight customization *searchlight-customization* 38 | 39 | *hl-Searchlight* 40 | Searchlight uses the |hl-Searchlight| group to highlight the current match. 41 | Defaults to |hl-ErrorMsg|. Example of setting to |hl-Incsearch|: > 42 | 43 | highlight link Searchlight Incsearch 44 | < 45 | 46 | *searchlight-update* *(Searchlight)* 47 | Searchlight's highlighting can be updated via: > 48 | 49 | :1Searchlight 50 | < 51 | *g:searchlight_disable_on_startup* 52 | Setting |g:searchlight_disable_on_startup| to 1 will prevent Searchlight from 53 | activating on startup. Defaults to 0. > 54 | 55 | let g:searchlight_disable_on_startup = 1 56 | < 57 | ============================================================================== 58 | 4. Known Issues *searchlight-issues* 59 | 60 | When using any search command like: "*" (|star|), |#|, etc at the beginning of 61 | a match and it is the only match, then searchlight will not trigger. 62 | 63 | One solution would be to trigger an update with mappings like so: > 64 | 65 | nnoremap * *:1Searchlight 66 | nnoremap # #:1Searchlight 67 | < 68 | However, this goes against the goal of having no mappings. Sad panda 69 | 70 | ============================================================================== 71 | Credits 72 | 73 | Thank you to both vim-searchhi & vim-searchant which inspired this plugin. 74 | 75 | 76 | vim:tw=78:ts=8:ft=help:norl: 77 | -------------------------------------------------------------------------------- /example.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PeterRincker/vim-searchlight/fefdc00ebdff34b3d6c54489c281956c7d8c4f2c/example.gif -------------------------------------------------------------------------------- /plugin/searchlight.vim: -------------------------------------------------------------------------------- 1 | if exists('g:loaded_searchlight') || &cp || !exists('##CursorMoved') || !has_key(v:, 'hlsearch') 2 | finish 3 | endif 4 | let g:loaded_searchlight = 1 5 | 6 | let s:enable = !get(g:, 'searchlight_disable_on_startup', 0) 7 | 8 | highlight default link Searchlight ErrorMsg 9 | 10 | if has('patch-8.2.4724') || has('nvim-0.10') 11 | highlight link CurSearch Searchlight 12 | finish 13 | endif 14 | 15 | command! -bar -bang -range=-1 Searchlight 16 | \ if == -1 | 17 | \ let s:enable = 1 | 18 | \ call s:activate() | 19 | \ else | 20 | \ call s:trigger() | 21 | \ endif 22 | 23 | map (searchlight) mapping() 24 | nnoremap