How can I disable all user mappings only for current buffer in vim? I've tried :mapclear
but it removed mappings for all buffers.
2 Answers
You might be looking for <buffer>
argument.
This argument ensures that the command or the mapping will be effective only in the local buffer rather than the global buffer.
To clear all the user-mapping in the local buffer, :mapclear <buffer>
should be used.
For more information, look at :h :map-<buffer>
-
You might misunderstand my question. The
<buffer>
argument is for removing local buffer mappings, but what I want to do is remove all mappings temporarily for the current buffer.– theJianJan 20, 2018 at 10:35 -
@theJian.. I'm looking up for this as well and ended up here. have you solved this? Oct 31, 2018 at 12:32
-
@JohnFredFadrigalan Unfortunately no, this snippet is the temporary solution I've used. gist.github.com/theJian/beb8519127b9209f644197a09620d939– theJianNov 1, 2018 at 8:41
Here is the temporary solution I've found so far.
let lowercase = 'abcdefghijklmnopqrstuvwxyz'
let uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
let numbers = '0123456789'
let punctuation = "<>`@#~!\"$%^&/()=+*-_.,;:?\\\'{}[] " " and space
for str in [lowercase, uppercase, numbers, punctuation]
for key in split(str, '\zs')
execute printf("noremap <silent> <buffer> <nowait> %s :call DO_SOMETHING_OR_NOTHING<cr>", key)
endfor
endfor
Basically this snippet will remap all the normal mappings for local buffer.
xxx
, do you also need to havexxx
disabled for the current buffer?