Hello Vim developers; attached is a small patch to the VimL runtime
ftplugin that extends its b:undo_ftplugin variable to clear away a set
of buffer-local maps, if assigned, so that they don't stick around if
the filetype changes.
There are similar problems in other ftplugins, such as php.vim's square
bracket maps. I'm willing to fix some of those up too, if appropriate.
--
Tom Ryder <https://sanctum.geek.nz/>
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups "vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.
>From cd130203ef7d0f968b9bfb85c4ca158472b19ab0 Mon Sep 17 00:00:00 2001
From: Tom Ryder <[email protected]>
Date: Thu, 5 Jul 2018 13:07:27 +1200
Subject: [PATCH] Add b:undo_ftplugin commands for Vim filetype maps
These buffer-local maps were remaining when the filetype was switched.
---
runtime/ftplugin/vim.vim | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/runtime/ftplugin/vim.vim b/runtime/ftplugin/vim.vim
index 61dc79db7..7f43adb77 100644
--- a/runtime/ftplugin/vim.vim
+++ b/runtime/ftplugin/vim.vim
@@ -55,6 +55,21 @@ if !exists("no_plugin_maps") && !exists("no_vim_maps")
vnoremap <silent><buffer> ]" :<C-U>exe "normal! gv"<Bar>call
search('^\(\s*".*\n\)\@<!\(\s*"\)', "W")<CR>
nnoremap <silent><buffer> [" :call search('\%(^\s*".*\n\)\%(^\s*"\)\@!',
"bW")<CR>
vnoremap <silent><buffer> [" :<C-U>exe "normal! gv"<Bar>call
search('\%(^\s*".*\n\)\%(^\s*"\)\@!', "bW")<CR>
+
+ " Add undo commands for the maps
+ let b:undo_ftplugin = b:undo_ftplugin
+ \ . '|silent! nunmap <buffer> [['
+ \ . '|silent! vunmap <buffer> [['
+ \ . '|silent! nunmap <buffer> ]]'
+ \ . '|silent! vunmap <buffer> ]]'
+ \ . '|silent! nunmap <buffer> []'
+ \ . '|silent! vunmap <buffer> []'
+ \ . '|silent! nunmap <buffer> ]['
+ \ . '|silent! vunmap <buffer> ]['
+ \ . '|silent! nunmap <buffer> ]"'
+ \ . '|silent! vunmap <buffer> ]"'
+ \ . '|silent! nunmap <buffer> ["'
+ \ . '|silent! vunmap <buffer> ["'
endif
" Let the matchit plugin know what items can be matched.
--
2.18.0