Reply to message «some custom key maps are invalid in my terminal vim», 
sent 04:16:57 05 November 2010, Friday
by H Xu:

> Hello everyone,
> 
> I found that I can't map some combined keys in my terminal vim. For
> example,key maps of  <C-tab>, <C-F9> are always invalid on my terminal
> vim on linux, but they are valid on gvim.
About <C-Tab>: most terminals send <Tab> when you enter <C-Tab>, so vim cannot 
distinguish it.
About <C-FN>: though my terminal sends different key sequences for <FN> and
<C-FN>, vim is not able to recognize it as <C-FN> and has no option like
    set <F1>=^[OP
for <C-FN>. I do not know, why vim has
    set <M-a>
and does not have
    set <C-F1>
, but you may still map <C-F1> by yourself:

    let s:TermKeys={}
    if !has("gui_running")
        if $TERM==#"xterm"
            let s:TermKeys["<C-F1>"]="\e[11;5~"
            let s:TermKeys["<C-F2>"]="\e[12;5~"
            <...>
            let s:TermKeys["<C-F12>"]="\e[24;5~"
        endif
    endif
    function s:GetTermKey(key)
        return get(s:TermKeys, a:key, a:key)
    endfunction
    function MapTerm(mapcmd, flags, lhs, rhs)
        execute a:mapcmd." ".a:flags." ".
               \substitute(a:lhs." ".a:rhs, '<[^>]*>',
                          \'\=s:GetTermKey(submatch(0))', 'g')
    endfunction
    call MapTerm("noremap", "", "<C-F1>", ":h<CR>")

Attachment: signature.asc
Description: This is a digitally signed message part.

Reply via email to