From dacd6d5de096248b007c316f9a566a91a99689fa Mon Sep 17 00:00:00 2001 From: Julian Prein Date: Wed, 28 Dec 2022 13:49:28 +0100 Subject: [PATCH] vim:keys:": Convert only pairs of quotes When converting double to single quotes with `"`, only pairs of quotes should be converted. This lowers the false positive rate by trying to make sure that the double quotes are really used for string quotation and not for something else (e.g. exactly these mappings). --- .config/vim/vimrc.d/40-keys.vim | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.config/vim/vimrc.d/40-keys.vim b/.config/vim/vimrc.d/40-keys.vim index 64968a6..fefb49e 100644 --- a/.config/vim/vimrc.d/40-keys.vim +++ b/.config/vim/vimrc.d/40-keys.vim @@ -244,9 +244,10 @@ noremap ][ ]] nnoremap :silent! %s/\v\s+$// vnoremap :silent! '<,'>s/\v\s+$// -" Convert double quotes to single -nnoremap " :silent! %s/"/'/g -vnoremap " :silent! '<,'>s/"/'/g +" Convert double quotes to single. Convert only pairs to lower the false +" positive rate. +nnoremap " :silent! %s/\v"([^"]*)"/'\1'/g +vnoremap " :silent! '<,'>s/\v"([^"]*)"/'\1'/g " Keep selection when changing the indentation in visual mode vnoremap > >gv