Mapping in my vimrc fails in Ubuntu

前端 未结 4 1056
挽巷
挽巷 2020-12-08 04:46

I want to map ctrl-tab to :tabn, and ctrl-shift-tab to :tabp.

I had it working for gVim in Windows XP, but moved it to my .vimrc in Ubuntu 9.10 and it doesn\'t work

相关标签:
4条回答
  • 2020-12-08 05:24

    In my case,
    I solved on rxvt-unicode (urxvt, v9.22) as below,

    terminal (.Xresource)
    URxvt.keysym.Control-Tab: \033[27;5;9~ 
    
    vim v8.0 (.vimrc) 
    map <Esc>[27;5;9~ :tabnext<CR>
    

    Good Luck!

    0 讨论(0)
  • 2020-12-08 05:36

    I used the blog and wiki posts from @nfm's answer and solved it:

    Put this in your .Xresources file (you can copy-paste in this case):

    xterm*VT100.Translations: #override \
                 Ctrl ~Shift <Key>Tab: string(0x1b) string("[27;5;9~") \n\
                 Ctrl Shift <Key>Tab: string(0x1b) string("[27;6;9~")
    

    Then do cd ; xrdb .Xresources and restart xterm.


    Put this in your .vimrc:

    !! Important - instead of XXXX you must type CTRL-V and then Esc OR copy-paste the whole text and run %s/\(set <F1[34]>=\)XXXX/\=submatch(1) . "\33"/g which is copy-pastable (insert it with <CTRL-R> +).

    set timeout timeoutlen=1000 ttimeoutlen=100
    set <F13>=XXXX[27;5;9~
    nnoremap <F13> gt
    set <F14>=XXXX[27;6;9~
    nnoremap <F14> gT
    

    And restart vim.

    Done.

    0 讨论(0)
  • 2020-12-08 05:36

    If you're using Ubuntu, you probably have something like Compiz enabled.

    I can't know for sure, but you should take a look at Compiz extensions and whether on of them defines that shortcut. I had a similar problem once, not with vim, but still.

    It could also be the X server that intercepts some keystrokes (example: xbindkeys).

    0 讨论(0)
  • 2020-12-08 05:43

    It's definitely a terminal issue.

    Apparently xterm, and lots of other terminal emulators, don't intercept ctrl-tab by default and just send a tab signal. This Vim wiki page states that ctrl-tab doesn't work for xterm, Eterm, and aterm. There's also this Arch linux form post claiming that it's a terminal issue.

    The solution can be found by combining the info from this blog post with this vim wiki for mapping keycodes. This gist of it is that you need to configure xterm to intercept and send a unique code for ctrl-tab and ctrl-shift-tab in your .Xresources file, then hack that into your .vimrc with some funky mappings.

    Long story short is that it's hard to do (still haven't got it working here) because xterm and vim both need to be tricked into doing it. I'm personally gonna move on and use another mapping... this issue is a serious time sucker and I don't think it's worth pressing on to get it working!

    Thanks for the help guys.

    0 讨论(0)
提交回复
热议问题