From e54b1fc71a5c12bd5020c94e7a2c977c39e74792 Mon Sep 17 00:00:00 2001 From: Julian Prein Date: Fri, 30 Aug 2024 18:11:12 +0200 Subject: [PATCH] vim:keys: WIP fix swapping of ]] and ][ Make ][ and ]] work like they used to with the new functionality through a workaround. The problem is that recursive mappings are evaluated at runtime not "compiletime" - which is what I would need in this situation. I still want both mappings blocks so that they are not entangled and I can turn each one off without affecting the other. --- .config/vim/vimrc.d/40-keys.vim | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.config/vim/vimrc.d/40-keys.vim b/.config/vim/vimrc.d/40-keys.vim index c00f596..98760af 100644 --- a/.config/vim/vimrc.d/40-keys.vim +++ b/.config/vim/vimrc.d/40-keys.vim @@ -274,13 +274,15 @@ vnoremap utc s/\v(^\|[^0-9])\zs[0-9]{10}\ze([^0-9]\|$)/\=strftime(" " TODO: [count] sections? (see :h [[) nnoremap [[ m':call search('^\S.*{', "bW") vnoremap [[ m':exe "normal! gv"call search('^\S.*{', "bW") -nnoremap ]] m':call search('^\S.*{', "W") -vnoremap ]] m':exe "normal! gv"call search('^\S.*{', "W") +" map ]] here and remap ][ down below for better modularization +nnoremap ][ m':call search('^\S.*{', "W") +vnoremap ][ m':exe "normal! gv"call search('^\S.*{', "W") " Match the behaviour of [[ and []. ]] forward to next '}' in the first column " and ][ fw to next '[', instead of the other way around. noremap ]] ][ -noremap ][ ]] +" TODO: fix this with the relaxed mappings by evaluating the current rhs of ]] +" nmap ][ ]] " Strip trailing whitespace nnoremap silent! %s/\v\s+$//