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(-) (limited to 'vim/after/ftplugin/diff.vim') 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(-) (limited to 'vim/after/ftplugin/diff.vim') 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(-) (limited to 'vim/after/ftplugin/diff.vim') 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 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 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'vim/after/ftplugin/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 -- cgit v1.2.3