From 611e83b1c87934ff262e6a76ed07015eeedd83a0 Mon Sep 17 00:00:00 2001 From: Julian Prein Date: Wed, 20 Nov 2024 12:46:53 +0100 Subject: [PATCH] vim:keys: Streamline [[ and ]] mappings Use the `s` flag, so that the position before the last jump is updated automatically. Use `` so that both normal and visual mode mappings become identical and can be merged. This has the added benefit that it now also maps in operator-pending mode. Complete the TODOs. --- .config/vim/vimrc.d/40-keys.vim | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.config/vim/vimrc.d/40-keys.vim b/.config/vim/vimrc.d/40-keys.vim index e6cf542..e9ba858 100644 --- a/.config/vim/vimrc.d/40-keys.vim +++ b/.config/vim/vimrc.d/40-keys.vim @@ -278,12 +278,12 @@ vnoremap utc s/\v(^\|[^0-9])\zs[0-9]{10}\ze([^0-9]\|$)/\=strftime(" " Relax mappings that jump to opening braces on first column: Just make sure " they are on an unindented line. This is useful for files that use a different " coding style guide than the kernel and similar. -" TODO: [count] sections? (see :h [[) -nnoremap [[ m':call search('\v^(\S.*)?\{', "bW") -vnoremap [[ m':exe "normal! gv"call search('\v^(\S.*)?\{', "bW") +" TODO: support [count] +" TODO: sections? (see :h [[ and :h section) +" TODO: exclusive and exclusive-linewise? +noremap [[ call search('\v^(\S.*)?\{', 'bsW') " TODO: map ]] here and remap ][ down below for better modularization -nnoremap ][ m':call search('\v^(\S.*)?\{', "W") -vnoremap ][ m':exe "normal! gv"call search('\v^(\S.*)?\{', "W") +noremap ][ call search('\v^(\S.*)?\{', 'sW') " Match the behaviour of [[ and []. ]] forward to next '}' in the first column " and ][ fw to next '[', instead of the other way around.