中显示选项卡关闭按钮

中显示选项卡关闭按钮

本文介绍了如何在 GVIM 中显示选项卡关闭按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请告诉我如何在 GVIM 中的每个标签页上显示关闭按钮.

Please let me know how to show the close button on each tab page in GVIM.

另外,如果我在打开多个标签页的情况下关闭 GVIM,是否可以设置警告?

Also, is it possible to set a warning if I am closing GVIM with multiple tab pages open?

推荐答案

显示关闭按钮

'tabline' 选项可以包含用于关闭标签按钮的 %X 标记,但这仅适用于标签行的控制台版本.:help 'guitablabel' 明确指出:

Showing the close button

The 'tabline' option can include a %X marker for the close tab button, but that only works for the console version of the tab line. :help 'guitablabel' explicitly states:

请注意,该选项不使用语法突出显示.%T 和 %X 项也被忽略.

所以,要真正得到你想要的东西,你必须切换到基于文本的(丑陋)标签行

So, to literally get what you want, you'd have to switch to the (uglier) text-based tab line with

:set guioptions-=e

但请注意,在 Vim 中不鼓励使用鼠标(即使您可能被其他应用程序(如 Web 浏览器选项卡)自定义为鼠标).如果您右键单击 GUI 选项卡标签,您也可以从弹出菜单中选择 |Close tab|.

But note that using the mouse (even though you may be customized to that by other applications like web browser tabs) is discouraged in Vim. If you right mouse button-click on a GUI tab label, you can alternatively also choose |Close tab| from the popup menu.

我认为这是不可能的;有一个 VimLeavePre 事件你可以挂钩,但它不能阻止 Vim 的关闭;操作(例如 :qall!)无法撤消.如果您习惯于始终通过映射或命令关闭 Vim,您可以覆盖它并在其中包含一个检查(使用 tabpagenr('$') > 1).

I don't think this is possible; there is a VimLeavePre event that you could hook into, but it cannot prevent the closing of Vim; the action (e.g. :qall!) cannot be undone. If you are used to closing Vim always via a mapping or command, you could overwrite that and include a check in there (using tabpagenr('$') > 1).

如果您担心丢失窗口/选项卡布局,请查看 Vim 会话(可以在后台自动持久化).这将允许使用先前打开的窗口重新启动 Vim.

If you're concerned with losing your window / tab layout, rather have a look at Vim sessions (which can be persisted automatically in the background). This will allow to re-launch Vim with the previously opened windows.

这篇关于如何在 GVIM 中显示选项卡关闭按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-31 20:58