From 0a5b6d07676fda8effe9fcdca6b7ebe04dc6ea5d Mon Sep 17 00:00:00 2001 From: Julian Prein Date: Wed, 17 Sep 2025 23:33:16 +0200 Subject: [PATCH] vim:keys: Only map v_* & v_# if they don't exist I learned just now that neovim added mappings for these by default in v0.8.0. But instead of checking for neovim, check for the existence of mappings in case vim adds these in the future too. --- .config/vim/vimrc.d/40-keys.vim | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.config/vim/vimrc.d/40-keys.vim b/.config/vim/vimrc.d/40-keys.vim index 68026cf..1dcc518 100644 --- a/.config/vim/vimrc.d/40-keys.vim +++ b/.config/vim/vimrc.d/40-keys.vim @@ -124,8 +124,12 @@ function! GetVisualSelection(escape = "", byteescape = 'n') return l:sel endfunction -vmap * /\V=GetVisualSelection('/\') -vmap # ?\V=GetVisualSelection('?\') +" In case these do not exist already (At the time of writing only Neovim adds +" mappings for these) +if maparg('*', 'v', 0, 1) == {} + vmap * /\V=GetVisualSelection('/\') + vmap # ?\V=GetVisualSelection('?\') +endif " Extended `*`. Starts vim search (without jump) and ripgrep nmap * :let @/ = '\<' . expand('') . '\>'