vim:keys:<leader>*: 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.
This commit is contained in:
2022-10-21 00:45:47 +02:00
parent 1aa6266200
commit a94f72c4d9

View File

@@ -91,8 +91,10 @@ endif
vnoremap * y/\V<C-R>=escape(@",'/\')<CR><CR>
vnoremap # y?\V<C-R>=escape(@",'?\')<CR><CR>
" Use ripgrep as search-engine for `*`
nmap <leader>* :Rg \b<C-R>=expand('<cword>')<CR>\b<CR>
" Extended `*`. Starts vim search (without jump) and ripgrep search for cword
nmap <leader>* :let @/ = '\<' . expand('<cword>') . '\>' <bar>
\ set hlsearch <bar>
\ Rg \b<C-R>=expand('<cword>')<CR>\b<CR>
" 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