在新(GUI)窗口中打开vim选项卡?

在新(GUI)窗口中打开vim选项卡?

问题描述:

我想将当前标签页移动到MacVim中的新(可视/真实)窗口中.

I'd like to move the current tab into a new (visual/real) window in MacVim.

这可能很困难,因为:

  • vim帮助中没有任何内容,只有极少数-没什么帮助-Google上的点击量
  • MacVim不支持它(链接,2009年)
  • there is nothing in the vim help and only very few - not helpful - hits on google
  • MacVim does not support it (link, 2009)

所以我想知道是否有人找到了实现这一目标的方法?

So I am wondering if someone has found a way to achieve this?

我认为您可以使用的最接近的方法是使用mksession

The closest I think you can come is using mksession

有几个缺点(例如,最初,次会话将打开比最终期望更多的缓冲区). 但是,它会 保留您的映射,设置,历史记录,窗口布局(如果您在当前选项卡中有多个窗口,它们将全部被克隆).

This will have several drawbacks (like, initially the secondary session will open a few more buffers than ultimately desired). However, it will preserve your mappings, settings, history, window layout (if you had multiple windows inside the current tab, they will all get cloned).

如果这个想法引起了您的兴趣,您可以考虑创建一个脚本,该脚本将从会话文件中过滤掉一部分(这是"Yust Another Vim Text Script").

If this idea tickles your fancy, you could look at creating a script that will filter parts out of the session file (which is Yust Another Vim Text Script)

:mksession! $HOME/detach.vim
:tabclose
:silent! !gvim remote --servername Detach -nR +'silent! source H:\detach.vim' +tabonly

  1. 保存所有当前窗口,映射,设置(:he mksession)
  2. 关闭我们要分离的标签
  3. 将会话(detach.vim)克隆到远程vim
    • :silent!(尽量不要说话太多)
    • !gvim remote --servername Detach; 启动新的远程Vim服务器(如果尚不存在),或与名为Detach
    • 的现有服务器对话
    • -nR 待办事项修复 这里是为了避免使用交换文件(因为我发现没有办法抑制可怕的ATTENTION消息[1]).但是,根据您的情况,这可能是不安全的建议,这就是为什么我也将-R设置为只读模式的原因
    • +'silent! source H:\detach.vim' +tabonly-在远程vim中,提供要克隆的会话的源,并仅保留活动选项卡(在步骤1中已关闭).
  1. save all current windows, mappings, settings (:he mksession)
  2. close the tab we are about to detach
  3. clone the session (detach.vim) into a remote vim
    • :silent! (try not to talk too much)
    • !gvim remote --servername Detach; launch a new remote Vim server if it doesn't yet exist, or talk to the existing server named Detach
    • -nR TODO Fix This is here to avoid the use of swapfiles (because I found no way to suppress the dreaded ATTENTION messages[1]). However, this may be unsafe advice depending on your situation, which is why I also include -R for read-only mode
    • +'silent! source H:\detach.vim' +tabonly -- In the remote vim, source the session to clone, and keep only the active tab (that was already closed in step 1.)

可以肯定,边缘有些粗糙,但是非常接近您的预期. 如果您感到舒适,可以放下-nR标志,然后单击一些烦人的交换文件注意消息(键盘: Q ).

A little rough around the edges, for sure, but quite close to what you intended, I feel. If you are comfortable, you can drop the -nR flags and just click through a few annoying swapfile attention messages (keyboard: Q).

[1] :he ATTENTION

  • 在Windows上,您可能要使用:silent! !start /b gvim ....,以防终端窗口粘住
  • 同样在Windows上,如果生成的gvim窗口太小,您可能会遇到烦人的行为. :simalt ~x序列是一种最大化窗口的简单方法(假设使用英语UI,因为x是Ma x imize的加速器)
  • 锦上添花的是,vim 7.3具有持久撤销"功能.参见例如:se undofile
  • on windows you might want to use :silent! !start /b gvim .... in case you have terminal windows sticking around
  • also on windows, you might get annoying behaviour if the resulting gvim window is too small. The :simalt ~x sequence is one hacky way to maximize the window (assuming English UI, because x is the accelerator for Maximize)
  • as icing on the cake, vim 7.3 has 'persistent undo'. See e.g. :se undofile