From 292ffffacbb29774ba4703969c55c826a22e1c8b Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Mon, 27 Aug 2018 16:39:30 +1200 Subject: Use search() in Vim diff section navigation maps This preserves the user's primary search pattern. --- vim/after/ftplugin/diff.vim | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/vim/after/ftplugin/diff.vim b/vim/after/ftplugin/diff.vim index eecc8b8c..31403cc3 100644 --- a/vim/after/ftplugin/diff.vim +++ b/vim/after/ftplugin/diff.vim @@ -9,8 +9,10 @@ if exists('g:no_plugin_maps') || exists('g:no_diff_maps') endif " Modify curly braces to navigate by diff block -nnoremap { ?^@@ -nnoremap } /^@@ +nnoremap { + \ :call search('\m^@@', 'bW') +nnoremap { + \ :call search('\m^@@', 'W') let b:undo_ftplugin .= '|nunmap {' \ . '|nunmap }' -- cgit v1.2.3 From e12868a39d215be0d0b2c05b645022ec44c71512 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Mon, 27 Aug 2018 16:40:09 +1200 Subject: Use local leader keys in Vim diff section nav maps --- vim/after/ftplugin/diff.vim | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/vim/after/ftplugin/diff.vim b/vim/after/ftplugin/diff.vim index 31403cc3..16ed5dee 100644 --- a/vim/after/ftplugin/diff.vim +++ b/vim/after/ftplugin/diff.vim @@ -9,12 +9,12 @@ if exists('g:no_plugin_maps') || exists('g:no_diff_maps') endif " Modify curly braces to navigate by diff block -nnoremap { +nnoremap [ \ :call search('\m^@@', 'bW') -nnoremap { +nnoremap ] \ :call search('\m^@@', 'W') -let b:undo_ftplugin .= '|nunmap {' - \ . '|nunmap }' +let b:undo_ftplugin .= '|nunmap [' + \ . '|nunmap ]' " Set mappings nmap p -- cgit v1.2.3 From 4097539ac5ebd4077bd3aa63c903c1f1e8a7c70c Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Mon, 27 Aug 2018 16:41:23 +1200 Subject: Silence Vim diff section navigation maps This is just to prevent the `:call search(...)` command from showing up in the command line when the map is invoked. --- vim/after/ftplugin/diff.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vim/after/ftplugin/diff.vim b/vim/after/ftplugin/diff.vim index 16ed5dee..798c7089 100644 --- a/vim/after/ftplugin/diff.vim +++ b/vim/after/ftplugin/diff.vim @@ -9,9 +9,9 @@ if exists('g:no_plugin_maps') || exists('g:no_diff_maps') endif " Modify curly braces to navigate by diff block -nnoremap [ +nnoremap [ \ :call search('\m^@@', 'bW') -nnoremap ] +nnoremap ] \ :call search('\m^@@', 'W') let b:undo_ftplugin .= '|nunmap [' \ . '|nunmap ]' -- cgit v1.2.3 From 7167128b2d2f8aa0436529c474718d71d9e20f2e Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Mon, 27 Aug 2018 17:16:59 +1200 Subject: Correct a comment --- vim/after/ftplugin/mail.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vim/after/ftplugin/mail.vim b/vim/after/ftplugin/mail.vim index 4b6c827c..3aa3fec3 100644 --- a/vim/after/ftplugin/mail.vim +++ b/vim/after/ftplugin/mail.vim @@ -64,7 +64,7 @@ let b:undo_ftplugin .= '|nunmap Q' \ . '|nunmap QQ' \ . '|xunmap Q' -" Maps using NewBlank() function above for quoted paragraph movement +" Maps using autoloaded function for quoted paragraph movement nnoremap [ \ :call mail#NewBlank(v:count1, 1, 0) nnoremap ] -- cgit v1.2.3 From 673c96515da477e2a4f14d9466153ff0874777aa Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Mon, 27 Aug 2018 17:18:05 +1200 Subject: Improve diff block navigation in Vim with function --- vim/after/ftplugin/diff.vim | 18 +++++++++++++++--- vim/autoload/diff.vim | 29 +++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 3 deletions(-) create mode 100644 vim/autoload/diff.vim diff --git a/vim/after/ftplugin/diff.vim b/vim/after/ftplugin/diff.vim index 798c7089..a52b3fdd 100644 --- a/vim/after/ftplugin/diff.vim +++ b/vim/after/ftplugin/diff.vim @@ -8,13 +8,25 @@ if exists('g:no_plugin_maps') || exists('g:no_diff_maps') finish endif -" Modify curly braces to navigate by diff block +" Maps using autoloaded function for quoted block movement nnoremap [ - \ :call search('\m^@@', 'bW') + \ :call diff#MoveBlock(v:count1, 1, 0) nnoremap ] - \ :call search('\m^@@', 'W') + \ :call diff#MoveBlock(v:count1, 0, 0) +onoremap [ + \ :call diff#MoveBlock(v:count1, 1, 0) +onoremap ] + \ :call diff#MoveBlock(v:count1, 0, 0) +xnoremap [ + \ :call diff#MoveBlock(v:count1, 1, 1) +xnoremap ] + \ :call diff#MoveBlock(v:count1, 0, 1) let b:undo_ftplugin .= '|nunmap [' \ . '|nunmap ]' + \ . '|ounmap [' + \ . '|ounmap ]' + \ . '|xunmap [' + \ . '|xunmap ]' " Set mappings nmap p diff --git a/vim/autoload/diff.vim b/vim/autoload/diff.vim new file mode 100644 index 00000000..32e9333a --- /dev/null +++ b/vim/autoload/diff.vim @@ -0,0 +1,29 @@ +" Move between diff block headers +function! diff#MoveBlock(count, up, visual) abort + + " Reselect visual selection + if a:visual + normal! gv + endif + + " Flag for the number of blocks passed + let l:blocks = 0 + + " Iterate through buffer lines + let l:num = line('.') + while a:up ? l:num > 1 : l:num < line('$') + let l:num += a:up ? -1 : 1 + if getline(l:num) =~# '^@@' + let l:blocks += 1 + if l:blocks == a:count + break + endif + endif + endwhile + + " Move to line if nonzero and not equal to the current line + if l:num != line('.') + execute 'normal '.l:num.'G' + endif + +endfunction -- cgit v1.2.3 From 595f866f02f5a49b339bdf358ee3760950f0f3a2 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Mon, 27 Aug 2018 17:18:35 +1200 Subject: Bump VERSION --- VERSION | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/VERSION b/VERSION index 51fdab64..fceba156 100644 --- a/VERSION +++ b/VERSION @@ -1,2 +1,2 @@ -tejr dotfiles v1.61.0 -Sun Aug 26 05:40:26 UTC 2018 +tejr dotfiles v1.62.0 +Mon Aug 27 05:18:35 UTC 2018 -- cgit v1.2.3