[英]How can I map Ctrl-TAB to something in Vim?
I'd like to map Ctrl-TAB
to gt
in Vim so that I can switch tabs with one keystroke.我想将Ctrl-TAB
映射到 Vim 中的gt
以便我可以一键切换选项卡。
I tried...我试过了...
nmap <C-T> gt
nmap <C-Tab> gt
nmap <C-TAB> gt
That didn't work.那没有用。 How do you say "the tab key" in Vimese? Vimese 中的“tab 键”怎么说?
它可以在 gvim 中映射,但终端看不到<Tab>
和<C-Tab>
之间的区别。
You can't.你不能。 Tab is already a control key, <Ci>
. Tab 已经是一个控制键<Ci>
。
It works on gVim.它适用于 gVim。 Just add this at the end of your ~/.gvimrc file:只需在 ~/.gvimrc 文件的末尾添加:
" Add keyboard shortcuts
map <C-Tab> gt
map <C-S-Tab> gT
I use the mintty
terminal in cygwin
.我在cygwin
中使用mintty
终端。 This terminal has an option of using ctrl-tab
to cycle between the various instances of cygwing or alternatively, you can use to go to the next or previous screen
window (so ctrl-tab
does the same as ctrl-a+n
and s-ctrl-tab
does the same as ctrl-a+p
. This last behavior is very convenient in my opinion. Check此终端可以选择使用ctrl-tab
在 cygwing 的各个实例之间循环,或者,您可以使用转到下一个或上一个screen
窗口(因此ctrl-tab
与ctrl-a+n
和s-ctrl-tab
的作用与ctrl-a+p
相同。在我看来,最后一种行为非常方便。检查
Using_Ctrl+Tab_to_switch_session_in_GNU_Screen 使用_Ctrl+Tab_to_switch_session_in_GNU_Screen
First, disable the Switch window option in Options > Keys .首先,禁用Options > Keys中的Switch window选项。 Then you can use the following maps.然后,您可以使用以下地图。
Note: you cannot simply copy and paste these into your .vimrc
.注意:您不能简单地将这些复制并粘贴到您的.vimrc
中。 Instead, where ^[[1;6I
is, you need to press Ctrl-V
while in insert mode and then type Ctrl-Shift-Tab
.相反,在^[[1;6I
所在的位置,您需要在插入模式下按Ctrl-V
,然后键入Ctrl-Shift-Tab
。 The same goes for ^[[1;5I
and Ctrl-Tab
. ^[[1;5I
和Ctrl-Tab
也是如此。
nnoremap ^[[1;6I :tabprevious<CR>
nnoremap ^[[1;5I :tabnext<CR>
inoremap ^[[1;6I <Esc>:tabprevious<CR>
inoremap ^[[1;5I <Esc>:tabnext<CR>
If you are on a mac, then you can use Karabiner to remap keys.如果您使用的是 Mac,那么您可以使用Karabiner重新映射键。 Here is how you can do it in steps:以下是您可以分步执行的方法:
Inside the <root>
node add the following configuration在<root>
节点内添加以下配置
<item> <name>c-tab to s-tab LEFT</name> <identifier>private.ctabtostabl</identifier> <autogen> __KeyToKey__ KeyCode::TAB, ModifierFlag::CONTROL_L, KeyCode::TAB, ModifierFlag::SHIFT_L </autogen> </item> <item> <name>c-tab to s-tab RIGHT</name> <identifier>private.ctabtostabr</identifier> <autogen> __KeyToKey__ KeyCode::TAB, ModifierFlag::CONTROL_R, KeyCode::TAB, ModifierFlag::SHIFT_R </autogen> </item>
After saving the xml file, go back to Karabiner preferences, this time to "Change Key" tab, push the "Reload XML" button, and check the newly minted options.保存 xml 文件后,返回 Karabiner 首选项,这次是“更改密钥”选项卡,按下“重新加载 XML”按钮,并检查新创建的选项。 Now your control-tab should become shift-tab!现在你的控制选项卡应该变成了移位选项卡!
This worked for me in MacVim这在 MacVim 中对我有用
:map <C-Tab> gt
It works in command mode.它在命令模式下工作。 Not in Edit mode.不在编辑模式下。
It does not work in vim in my terminal.它在我的终端中的 vim 中不起作用。
I got this working with Konsole 19.12.3.我用 Konsole 19.12.3 得到了这个。 Here's how:就是这样:
Backtab+Ctrl+Ansi
(or probably just Backtab+Ctrl-Ansi if you have a non-ANSI keyboard) to \E[27;6;9~
. Backtab+Ctrl+Ansi
(或者如果您有非 ANSI 键盘,可能只是 Backtab+Ctrl-Ansi)绑定到\E[27;6;9~
。 Use the test area to confirm that the binding is working;使用测试区确认绑定是否正常; it should echo the sequence above.它应该与上面的顺序相呼应。 Delete any binding that conflicts with it.删除任何与之冲突的绑定。Tab+Ctrl+Ansi
(or non-ANSI equivalent) to \E[27;5;9~
.将Tab+Ctrl+Ansi
(或非 ANSI 等效项)绑定到\E[27;5;9~
。nnoremap <C-Tab> :tabn<CR>
and nnoremap <CS-Tab> :tabp<CR>
在您的 .vimrc 中添加以下形式的绑定: nnoremap <C-Tab> :tabn<CR>
和nnoremap <CS-Tab> :tabp<CR>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.