{"id":13850484,"url":"https://github.com/qxxxb/vim-searchhi","last_synced_at":"2025-07-12T22:30:38.200Z","repository":{"id":34228617,"uuid":"170034588","full_name":"qxxxb/vim-searchhi","owner":"qxxxb","description":"Highlight the current search result differently","archived":false,"fork":false,"pushed_at":"2022-04-03T22:51:40.000Z","size":7499,"stargazers_count":47,"open_issues_count":5,"forks_count":6,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-08-05T20:32:42.734Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Vim script","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/qxxxb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-02-10T22:27:00.000Z","updated_at":"2024-07-25T13:48:06.000Z","dependencies_parsed_at":"2022-08-08T00:02:09.410Z","dependency_job_id":null,"html_url":"https://github.com/qxxxb/vim-searchhi","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qxxxb%2Fvim-searchhi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qxxxb%2Fvim-searchhi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qxxxb%2Fvim-searchhi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qxxxb%2Fvim-searchhi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/qxxxb","download_url":"https://codeload.github.com/qxxxb/vim-searchhi/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225839506,"owners_count":17532305,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-04T20:01:14.551Z","updated_at":"2024-11-22T03:31:28.497Z","avatar_url":"https://github.com/qxxxb.png","language":"Vim script","funding_links":[],"categories":["Vim script","Vim Script"],"sub_categories":[],"readme":"# vim-searchhi\n\nHighlight the current search result in a different style than the other search\nresults.\n\n![Demo gif](https://raw.githubusercontent.com/qxxxb/vim-searchhi/assets/demo.gif)\n\n## Credits\n\nThis plugin would not have existed without [vim-searchant]. It uses the same\nbasic implementation for highlighting the current search result.\n\n## Features\n\n- Smooth integration with standard search as well as other search-enhancing\n  plugins (e.g. [vim-anzu], [vim-asterisk]).\n\n- Uses a custom highlight group for the cursor when it's inside a search result.\n\n- Behaves appropriately in Visual mode.\n\n- Highlighting is updated predictably when the cursor is moved, as well as\n  when switching buffers and windows. It can also be toggled with custom\n  autocommands.\n\n- User autocommands are provided and executed when highlighting is turned on\n  and off.\n\n**Note**: This plugin uses a lot of `\u003cPlug\u003e` mappings. An alternative plugin is\n[vim-searchlight], which has the same basic functionality but doesn't require\nany mappings.\n\n## Quick start\n```vim\nnmap n \u003cPlug\u003e(searchhi-n)\nnmap N \u003cPlug\u003e(searchhi-N)\nnmap * \u003cPlug\u003e(searchhi-*)\nnmap g* \u003cPlug\u003e(searchhi-g*)\nnmap # \u003cPlug\u003e(searchhi-#)\nnmap g# \u003cPlug\u003e(searchhi-g#)\nnmap gd \u003cPlug\u003e(searchhi-gd)\nnmap gD \u003cPlug\u003e(searchhi-gD)\n\nvmap n \u003cPlug\u003e(searchhi-v-n)\nvmap N \u003cPlug\u003e(searchhi-v-N)\nvmap * \u003cPlug\u003e(searchhi-v-*)\nvmap g* \u003cPlug\u003e(searchhi-v-g*)\nvmap # \u003cPlug\u003e(searchhi-v-#)\nvmap g# \u003cPlug\u003e(searchhi-v-g#)\nvmap gd \u003cPlug\u003e(searchhi-v-gd)\nvmap gD \u003cPlug\u003e(searchhi-v-gD)\n\nnmap \u003csilent\u003e \u003cC-L\u003e \u003cPlug\u003e(searchhi-clear-all)\nvmap \u003csilent\u003e \u003cC-L\u003e \u003cPlug\u003e(searchhi-v-clear-all)\n```\n\nIntegration with [vim-anzu]:\n```vim\nlet g:searchhi_user_autocmds_enabled = 1\nlet g:searchhi_redraw_before_on = 1\n\naugroup searchhi\n    autocmd!\n    autocmd User SearchHiOn AnzuUpdateSearchStatusOutput\n    autocmd User SearchHiOff echo g:anzu_no_match_word\naugroup END\n```\n\nExample with [vim-asterisk]:\n```vim\nmap * \u003cPlug\u003e(asterisk-*)\u003cPlug\u003e(searchhi-update)\nmap # \u003cPlug\u003e(asterisk-#)\u003cPlug\u003e(searchhi-update)\nmap g* \u003cPlug\u003e(asterisk-g*)\u003cPlug\u003e(searchhi-update)\nmap g# \u003cPlug\u003e(asterisk-g#)\u003cPlug\u003e(searchhi-update)\n\nmap z* \u003cPlug\u003e(asterisk-z*)\u003cPlug\u003e(searchhi-update)\nmap z# \u003cPlug\u003e(asterisk-z#)\u003cPlug\u003e(searchhi-update)\nmap gz* \u003cPlug\u003e(asterisk-gz*)\u003cPlug\u003e(searchhi-update)\nmap gz# \u003cPlug\u003e(asterisk-gz#)\u003cPlug\u003e(searchhi-update)\n```\n\n## Customization\n\n### Highlight style\n\nThe current search result is highlighted with `CurrentSearch`, and the cursor\nwhen it's inside a search result is highlighted with `SearchCursor`. Example:\n```vim\nhighlight CurrentSearch\n    \\ cterm=reverse,bold ctermfg=108 ctermbg=235\n    \\ gui=reverse,bold guifg=#8ec07c guibg=#282828\n\nhighlight link SearchCursor WarningMsg\n```\n\nBy default, `CurrentSearch` is linked to `Incsearch`, which works nicely if your\n`Incsearch` and `Search` highlight groups are visually distinguishable.\n`SearchCursor` is linked to `Normal` by default.\n\n### Autocommands\n\nThe autocommands `SearchHiOn` and `SearchHiOff` are executed when highlighting\nis turned on or off. Below is an example that blinks the cursor when search\nhighlighting is turned on, making the cursor easier to find. [vim-anzu] is also\nused to echo the search count.\n```vim\nlet g:searchhi_user_autocmds_enabled = 1\nlet g:searchhi_redraw_before_on = 1\n\naugroup searchhi\n    autocmd!\n\n    autocmd User SearchHiOn\n        \\ set guicursor=\n            \\c-sm:block,i-ci-ve:ver25,r-cr-o:hor20,\n            \\n-v:block-blinkwait20-blinkon20-blinkoff20 |\n        \\ AnzuUpdateSearchStatusOutput\n\n    autocmd User SearchHiOff set guicursor\u0026 | echo g:anzu_no_match_word\naugroup END\n```\n\n### Autocommands for toggling search highlighting\n\nHighlighting for all search results can be toggled with custom autocommands.\nExample:\n```vim\nlet g:searchhi_clear_all_autocmds = 'InsertEnter'\nlet g:searchhi_update_all_autocmds = 'InsertLeave'\n```\n\n**Note**: Using `CursorMoved` for these will cause issues. If you want search\nhighlighting to be cleared as soon as the cursor moves, use this:\n\n```vim\nlet g:searchhi_clear_all_asap = 1\n```\n\nBecause `g:searchhi_clear_all_asap` and `g:searchhi_clear_all_autocmds` both\nuse a hack that directly sets `nohlsearch`, you may also need to use the\nfollowing maps to make sure that `incsearch` works properly when searching:\n\n```vim\nnmap / \u003cPlug\u003e(searchhi-/)\nnmap ? \u003cPlug\u003e(searchhi-?)\n\nvmap / \u003cPlug\u003e(searchhi-v-/)\nvmap ? \u003cPlug\u003e(searchhi-v-?)\n```\n\n[vim-searchant]: https://github.com/timakro/vim-searchant\n[vim-anzu]: https://github.com/osyo-manga/vim-anzu\n[vim-asterisk]: https://github.com/haya14busa/vim-asterisk\n[vim-searchlight]: https://github.com/PeterRincker/vim-searchlight\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqxxxb%2Fvim-searchhi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fqxxxb%2Fvim-searchhi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqxxxb%2Fvim-searchhi/lists"}