vim cant map <C-Tab> to :tabnext

家住魔仙堡 提交于 2019-11-30 09:23:09
nfm

Are you using xterm? If so, you can't map ctrl-tab without a lot of hackery. xterm and many other terminal emulators don't recognise ctrl-tab and simply send a tab character.

See my answer here for more details: Mapping <C-Tab> in my vimrc fails in Ubuntu

Or you can just use gvim if that is suitable - it should work without any mucking around.

Something is probably blocking vim from seeing the C-Tab. This could be your terminal or your window manager.

On some OSes/WMs you can set exceptions to the window manager shortcuts, but how you do this varies crazily between the WMs.

I'm not sure if there is a solution if it is your terminal blocking the key presses.

oh ... is it need to be mapped? just use this predefined combos:

  • gt: == :tabnext

  • gT: == :tabprevious

  • [n]gt: == jump to N tab , e.g. 1gt , 3gt

defining to many short keys is easy, but how can you remember all of them and don't mixing them up with 'ctrl + tab' , 'alt + tab' ( common and usual short keys in most OS )

check this page for more details : http://vim.wikia.com/wiki/Alternative_tab_navigation

All you need is xterm.

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!