vim 无法映射到:选项卡下一个

发布于 2024-09-04 11:31:22 字数 386 浏览 4 评论 0原文

我的 .vimrc 中有以下映射:

map <C-S-Tab> :tabprevious<CR>
nmap <C-S-Tab> :tabprevious<CR>
imap <C-S-Tab> <Esc>:tabprevious<CR>i

map <C-Tab> :tabnext<CR>
nmap <C-Tab> :tabnext<CR>
imap <C-Tab> <Esc>:tabnext<CR>i

我想用 Strg+Tab 向前切换选项卡,用 Strg+Shift+Tab 向后切换选项卡。为什么这个映射不起作用?

I have the following mappings in my .vimrc:

map <C-S-Tab> :tabprevious<CR>
nmap <C-S-Tab> :tabprevious<CR>
imap <C-S-Tab> <Esc>:tabprevious<CR>i

map <C-Tab> :tabnext<CR>
nmap <C-Tab> :tabnext<CR>
imap <C-Tab> <Esc>:tabnext<CR>i

I want to switch the tabs with Strg+Tab forward and with Strg+Shift+Tab backward. Why does this mapping not work?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

清眉祭 2024-09-11 11:31:22

您使用的是 xterm 吗?如果是这样,您就无法在不进行大量黑客操作的情况下映射 ctrl-tab 。 xterm 和许多其他终端模拟器无法识别 ctrl-tab,而只是发送 tab 字符。

有关更多详细信息,请参阅我的答案: 映射;我的 vimrc 在 Ubuntu 中失败了

或者你可以使用 gvim 如果合适的话 - 它应该可以正常工作而无需任何处理。

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.

她比我温柔 2024-09-11 11:31:22

可能有什么东西阻止了 vim 查看 C-Tab。这可能是您的终端或窗口管理器。

在某些操作系统/WM 上,您可以对窗口管理器快捷方式设置例外,但是不同 WM 之间的操作方式差异很大。

我不确定如果您的终端阻止按键,是否有解决方案。

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.

失眠症患者 2024-09-11 11:31:22

哦……需要贴图吗?只需使用这个预定义的组合:

  • gt: == :tabnext

  • gT: == :tabprevious

  • [n] gt: == 跳转到 N 个 tab ,例如 1gt 、 3gt

定义很多快捷键很容易,但是你怎么能记住所有的快捷键呢?不要将它们与“ctrl + tab”、“alt + tab”(大多数操作系统中常见的快捷键)混淆,

请查看此页面以获取更多详细信息:http://vim.wikia.com/wiki/Alternative_tab_navigation

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

小草泠泠 2024-09-11 11:31:22

您所需要的只是xterm

将其放入您的 .Xresources 文件中(在本例中您可以复制粘贴):

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~")

然后执行 cd ; xrdb .Xresources 并重新启动 xterm。


将其放入您的 .vimrc 中:

!!重要 - 您必须输入 CTRL-V,然后输入 Esc,而不是 XXXX 复制粘贴整个文本并运行 %s/\(设置=\)XXXX/\=submatch(1) 。 “\33”/g 可复制粘贴(使用 + 插入)。

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

并重新启动vim。

完毕。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文