在 Vim 中撤消关闭选项卡
我关闭了 vim 中的一个选项卡,然后立即意识到我需要重新打开它以进行某些操作。 Vim 7.2 中有没有办法撤消关闭选项卡?
I close a tab in vim and immediately realize I need to re-open it again for something. Is there a way to undo close tab in Vim 7.2?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
您的文件可能仍在缓冲区中打开:
要重新打开缓冲区 18,例如:
Your file is probably still open in a buffer:
To reopen buffer 18, for example:
在新选项卡中重新打开最近关闭的文件
编辑:请使用 greyfade 的答案。 我不喜欢我的答案,但我将其保留在这里以供参考和有用的评论信息。
Reopens recently closed file in new tab
Edit: Please use greyfade's answer. I don't like my answer, but I'm keeping it here for references and useful comment info.
我正在使用 MRU(最近使用的文件)插件。 这样我就可以编辑刚刚编辑的最后 30 个文件
以下是 MRU 插件元数据:
I'm using an MRU (most recently used files) plugin. So I can edit the last 30 files I've just edited
Here are the MRU plugin metadata:
简单的答案是否定的,没有任何内置的东西。
但一个可行的解决方案是使用像优秀的 BufExplorer。 由于它默认首先列出最近使用的缓冲区,因此重新打开关闭的选项卡就像按
\bet
一样简单Simple answer is no, there is nothing built-in.
But a workable solution would be to use a plug-in like the excellent BufExplorer. Since it defaults to listing the most recently used buffers first, reopening a closed tab would be as simple as pressing
\bet
使用 Ben 建议的插件: BufExplorer Github Mirror
在他的回答中,必须按
是t
。 添加一点快捷方式:这样只需
t
即可完成工作。Use the plug-in Ben Suggested: BufExplorer Github Mirror
In his answer one would have to press
<Leader>be<Down>t
. Adding a bit shortcut:So that simply
<leader>t
would do the work.如果有一个 BufferClose 事件,这会很容易...... 但似乎它不可能,因为不可能创建窗口。
但对于选项卡,我们可以通过保存选项卡计数并计算
TabLeave
和TabEnter
之间的差异来检测选项卡是否已关闭。用法:
tr
在新选项卡上重新打开最后关闭的选项卡(假设该选项卡只有一个缓冲区):If there were a
BufferClose
event this would be easy... but it seems that it is not possible since it is not possible for window creation.But in the case of tabs we can detect if a tab was closed by keeping a tab count and counting the difference between
TabLeave
andTabEnter
.Usage:
<leader>tr
reopens the last closed tab on a new tab (supposing the tab had only a single buffer):