diff --git a/runtime/ftplugin/go.vim b/runtime/ftplugin/go.vim index 7823fb3e77..508e59cc55 100644 --- a/runtime/ftplugin/go.vim +++ b/runtime/ftplugin/go.vim @@ -49,26 +49,33 @@ if !exists('*' .. expand('') .. 'GoKeywordPrg') endfunc endif -noremap ]] call GoFindSection('next_start', v:count1) -noremap ][ call GoFindSection('next_end', v:count1) -noremap [[ call GoFindSection('prev_start', v:count1) -noremap [] call GoFindSection('prev_end', v:count1) +if !exists("no_plugin_maps") && !exists("no_go_maps") + noremap ]] call GoFindSection('next_start', v:count1) + noremap ][ call GoFindSection('next_end', v:count1) + noremap [[ call GoFindSection('prev_start', v:count1) + noremap [] call GoFindSection('prev_end', v:count1) + let b:undo_ftplugin ..= '' + \ . '| unmap ]]' + \ . '| unmap ][' + \ . '| unmap [[' + \ . '| unmap []' +endif function! GoFindSection(dir, count) - mark ' - let c = a:count - while c > 0 - if a:dir == 'next_start' - keepjumps call search('^\(type\|func\)\>', 'W') - elseif a:dir == 'next_end' - keepjumps call search('^}', 'W') - elseif a:dir == 'prev_start' - keepjumps call search('^\(type\|func\)\>', 'bW') - elseif a:dir == 'prev_end' - keepjumps call search('^}', 'bW') - endif - let c -= 1 - endwhile + mark ' + let c = a:count + while c > 0 + if a:dir == 'next_start' + keepjumps call search('^\(type\|func\)\>', 'W') + elseif a:dir == 'next_end' + keepjumps call search('^}', 'W') + elseif a:dir == 'prev_start' + keepjumps call search('^\(type\|func\)\>', 'bW') + elseif a:dir == 'prev_end' + keepjumps call search('^}', 'bW') + endif + let c -= 1 + endwhile endfunction let &cpo = s:cpo_save