From 533e82cb81be97be772c5be3c2c7bc72fdd58f22 Mon Sep 17 00:00:00 2001 From: Julian Prein Date: Fri, 30 May 2025 14:49:16 +0200 Subject: [PATCH] vim:keys: Add :keeppatterns to substituting vmaps All of these should not modify @/. --- .config/vim/vimrc.d/40-keys.vim | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.config/vim/vimrc.d/40-keys.vim b/.config/vim/vimrc.d/40-keys.vim index 49aa9bd..d359360 100644 --- a/.config/vim/vimrc.d/40-keys.vim +++ b/.config/vim/vimrc.d/40-keys.vim @@ -275,7 +275,7 @@ augroup END " Convert Unix timestamp to human readable " Mnemonic: "Unix timestamp convert" with pun to UTC nnoremap utc ciw=strftime("%F %T", @") -vnoremap utc '<,'>s/\v(^\|[^0-9])\zs[0-9]{10}\ze([^0-9]\|$)/\=strftime("%F %T",submatch(0))/g +vnoremap utc keepp '<,'>s/\v(^\|[^0-9])\zs[0-9]{10}\ze([^0-9]\|$)/\=strftime("%F %T",submatch(0))/g " TODO: sec that uses the `duration` alias from zsh @@ -296,13 +296,13 @@ noremap ]] ][ " nmap ][ ]] " Strip trailing whitespace -nnoremap silent! %s/\v\s+$// -vnoremap silent! '<,'>s/\v\s+$// +nnoremap keepp silent! %s/\v\s+$// +vnoremap keepp silent! '<,'>s/\v\s+$// " 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 +nnoremap " keepp silent! %s/\v"([^"]*)"/'\1'/g +vnoremap " keepp silent! '<,'>s/\v"([^"]*)"/'\1'/g " Betterâ„¢ >> and <<. When using tabs for indentation and spaces for alignment, " vim's behaviour is pretty disappointing since it will convert the indentation @@ -489,7 +489,7 @@ augroup macro_type augroup END " Escape underscores (useful when writing LaTeX) -vmap \_ '<,'>s/\v(^[^\\])\zs\ze_/\\/g +vmap \_ keepp '<,'>s/\v(^[^\\])\zs\ze_/\\/g " TODO: make `gf` open absolute paths relative to PWD if possible "