I'm just learning to use vimscript and have put the following
into a file:
==================================
" To become global and will be assigned to
" from outside once the script works:
let s:mapkeymap = {'x':'whatever'} " and so on...

function! MapKeymap()
    let char = getchar()
    if char =~ '^\s$'
        let &l:keymap = "" " unset 'keymap'
    elseif has_key(s:mapkeymap,char)
        let &l:keymap = s:mapkeymap[char]
    else
        echoerr 'No keymap assigned to "'.char.'"!'
    endif
endfunction

:inoremap <F12>k <C-\><C-O>:call MapKeymap()<CR>
=======================================================

However when I source the file, and then do <F12>kx in
insert mode I get the literal string
"^B:setlocal keymap=whatever" inserted instead of
the keymap being set. What am I doing wrong?

/bpj

--
You received this message from the "vim_use" 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

Reply via email to