some custom key maps are invalid in my terminal vim

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

some custom key maps are invalid in my terminal vim

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.

--
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 | Threaded
Open this post in threaded view
|

Re: some custom key maps are invalid in my terminal vim

H Xu
Why does this happen? Thanks.

H Xu
2010/11/5

On 11/5/10, H Xu <[hidden email]> wrote:
> 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.
>

--
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 | Threaded
Open this post in threaded view
|

Re: some custom key maps are invalid in my terminal vim

Nikolay Aleksandrovich Pavlov
In reply to this post by H Xu
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>")

signature.asc (205 bytes) Download Attachment