From a94f72c4d954a09c33d2390594b99a1c36d7b0f3 Mon Sep 17 00:00:00 2001 From: Julian Prein Date: Fri, 21 Oct 2022 00:45:47 +0200 Subject: [PATCH] vim:keys:*: Start vim's search too Additionally to start the search with ripgrep, start a vim search as well. That way navigation between search results in the opened file is easier. The register is modified directly and hlsearch is turned on manually instead of using the builtin `*`, so that the cursor does not move to the next result in the current file. --- .config/vim/vimrc.d/40-keys.vim | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.config/vim/vimrc.d/40-keys.vim b/.config/vim/vimrc.d/40-keys.vim index f8f3df3..3d354c3 100644 --- a/.config/vim/vimrc.d/40-keys.vim +++ b/.config/vim/vimrc.d/40-keys.vim @@ -91,8 +91,10 @@ endif vnoremap * y/\V=escape(@",'/\') vnoremap # y?\V=escape(@",'?\') -" Use ripgrep as search-engine for `*` -nmap * :Rg \b=expand('')\b +" Extended `*`. Starts vim search (without jump) and ripgrep search for cword +nmap * :let @/ = '\<' . expand('') . '\>' + \ set hlsearch + \ Rg \b=expand('')\b " Select last pasted text in same visual mode as it was selected (v, V, or ^V) " Taken from: https://vim.fandom.com/wiki/Selecting_your_pasted_text