I just learned about vimscript. I'm trying to write a small vimscript that'll kinda copy what this does, but more verbosely and very explicitly. (The first case would case typing a (
will insert ()
)
" make keymappings
for [opener, closer] in {'(': ')'}
inoremap l:opener <C-r>=InsertPair(opener, closer)<CR>
endfor
" Typing the opener will also insert the closer
function! InsertPair(open, close)
return a:open . a:close . "\<Left>"
endfunction
But I ran into a problem. The inoremap
s aren't working as planned - they're remapping the literal chars l
:
o
p
e
n
e
r
instead of the value of the local variable named opener ((
).