【发布时间】:2016-02-01 13:02:26
【问题描述】:
我正在使用 Firefox,并安装了 vimperator。很好,但我找不到使用热键关闭右侧标签的方法。你能告诉我怎么做吗?谢谢。
【问题讨论】:
-
对不起,我的问题不清楚,我的意思是如何配置热键来替换当前选项卡上的“向右关闭选项卡”菜单项。
标签: firefox vimperator
我正在使用 Firefox,并安装了 vimperator。很好,但我找不到使用热键关闭右侧标签的方法。你能告诉我怎么做吗?谢谢。
【问题讨论】:
标签: firefox vimperator
将以下代码放入您的.vimperatorrc 文件中。它分别定义了命令:closealltoright 和:closealltoleft 以及绑定v> 和v。在以“map”开头的行中根据需要更改绑定。
js <<EOF
closeAllToRight = function () {
var current = tabs.getTab();
var currentIx = tabs.index(current);
var nexttab = current.nextElementSibling;
var N = tabs.count;
var numToClose = N - (currentIx + 1);
tabs.remove(nexttab, numToClose);
}
closeAllToLeft = function () {
var current = tabs.getTab();
var currentIx = tabs.index(current);
var firsttab = tabs.getTab(0);
var N = tabs.count;
var numToClose = currentIx;
tabs.remove(firsttab, numToClose);
}
EOF
" close tabs to left
map v< :js closeAllToLeft()<CR>
" close tabs to right
map v> :js closeAllToRight()<CR>
command! closealltoright :js closeAllToRight()
command! closealltoleft :js closeAllToLeft()
我已将这两个命令上传为Gist。
command! closetabstoleft
\ -description "Close all tabs to the left of the current tab"
\ -js
\ var firstTab = tabs.getTab(0);
\ var numToClose = tabs.getTab().dactylOrdinal - 1;
\ tabs.remove(firstTab, numToClose);
command! closetabstoright
\ -description "Close all tabs to the right of the current tab"
\ -js
\ tabIndex = tabs.getTab().dactylOrdinal - 1;
\ var nextTabIndex = tabIndex + 1;
\ var firstTab = tabs.getTab(nextTabIndex);
\ var N = tabs.allTabs.length;
\ var numToClose = N - nextTabIndex;
\ tabs.remove(firstTab, numToClose);
map v< -ex closetabstoleft
map v> -ex closetabstoright
为方便起见,我已将这些放在gist 中。
更多选项卡命令可以在我的Pentadactyl folder 中找到(命令和绑定在.pentadactylrc,但可能依赖于utils.js 中定义的函数)。
【讨论】:
tabs. 或buffers. 并使用制表符完成来查看可用的方法。如果不全面了解(未记录的)vimperator/dactyl 架构,其他事情就很难解决。如果您对 webdev(或者更好的 FF 扩展开发)有经验,这可能会更容易一些,但我没有。如果我需要一些东西,通常是源代码查找和命令行试错的碰巧问题。
.pentadactylrc 和 utils.js 文件)。不幸的是,代码可能需要修改才能在 vimperator 上运行。通常它相当简单(例如将dactyl. 更改为liberator.),但有时可能更难。我确实有一个.vimperatorrc 文件,但里面没有太多内容。
buffers. 应该是buffer.
将map <your_key_binding> gt :bd -s left<CR> 添加到您的 vimperatorrc。
说明:
gt 切换到下一个右侧选项卡,:bd -s left 删除此选项卡并在此之后切换到左侧选项卡。
【讨论】: