我想阻止*noremap
命令重新映射现有序列,但前提是此序列对缓冲区是本地的:
noremap a b
" Will fail, must succeed
noremap <buffer> <unique> a c
noremap <buffer> a b
" Will fail, OK
noremap <unique> <buffer> a c
noremap a b
noremap <buffer> a c
" Will fail, OK
noremap <unique> <buffer> a d
答案 0 :(得分:1)
对于较新的vim,可以使用maparg()
第四个参数:
let oldmap=maparg('a', '', 0, 1)
if empty(oldmap) || !oldmap.buffer
noremap <buffer> a c
endif
或更好(也支持更旧的vim),但需要frawor:
execute frawor#Setup('0.0', {'@/mappings': '0.0'})
let oldmap=s:_r.map.maparg('a', 'n', 0)
if empty(oldmap) || !oldmap.buffer
noremap <buffer> a c
endif