Is it somehow possible to have different search patterns per window or buffer, ie. I want to search for term A in window/buffer A and term B in window/buffer B so that using hlsearch
, highlights different things in e.g. a split in parallel.
You can use :autocmd
s to switch the current search pattern (register /
) as you move along windows and buffers, but Vim will never highlight different patterns at the same time, as this still is a single global register, just being multiplexed.
Apart from searching, you can highlight different patterns (also with different colors) via the built-in :match
, :2match
, :3match
, and :call matchadd()
. These are window-local.
Finally, there are plugins like my Mark plugin that offer highlighting, searching, jumping to next match (similar to the built-in search), for multiple patterns. (The plugin page has links to alternative plugins.)