移动相邻的选项卡以拆分? [英] Move adjacent tab to split?

查看:23
本文介绍了移动相邻的选项卡以拆分?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一种简单的方法可以将 Vim 中的相邻选项卡作为拆分移动到当前窗口?

Is there an easy way to move an adjacent tab in Vim to current window as a split?

环顾四周时,我看到了一个邮件列表讨论,有人说这是操作 Ctrl+WT 的相反操作,但没有提供解决方案.

While looking around I reached a mailing list discussion where someone said it's the reverse of the operation Ctrl+W,T without providing the solution.

推荐答案

我提供了两种解决方案,第一种是我自己检查过的,我可以保证它有效.第二个,我正在尝试.
第一个解决方案:安装这个插件 http://www.vim.org/scripts/script.php?script_id=1961 只需创建文件夹 ~/.vim/plugin 并将文件 Tabmerge.vim 下载到该文件夹​​中.然后,当您有两个选项卡并键入

I am providing two solutions, the first one I checked myself and I can guarantee it's working. The second, I am trying soon.
First solution: install this plugin http://www.vim.org/scripts/script.php?script_id=1961 by simply creating the folder ~/.vim/plugin and downloading the file Tabmerge.vim into the folder. Then, when you have two tabs and you type

:Tabmerge

您将两个选项卡合二为一,水平拆分并顶部对齐.查看链接以查找完整的使用指南.

或者,查看此页面 http://vim.wikia.com/wiki/Move_current_window_between_tabs 以获取两个函数的代码在选项卡之间移动当前窗口.这里的功能(我还没有尝试过):

you will merge the two tabs into one, splitted horizontally and top aligned. Check out the link to find a complete usage guide.

Alternatively, check out this page http://vim.wikia.com/wiki/Move_current_window_between_tabs for the code of two functions to move current window between tabs. Here the functions (which I didn't try yet):

function MoveToPrevTab()
  "there is only one window
  if tabpagenr('$') == 1 && winnr('$') == 1
    return
  endif
  "preparing new window
  let l:tab_nr = tabpagenr('$')
  let l:cur_buf = bufnr('%')
  if tabpagenr() != 1
    close!
    if l:tab_nr == tabpagenr('$')
      tabprev
    endif
    sp
  else
    close!
    exe "0tabnew"
  endif
  "opening current buffer in new window
  exe "b".l:cur_buf
endfunc

function MoveToNextTab()
  "there is only one window
  if tabpagenr('$') == 1 && winnr('$') == 1
    return
  endif
  "preparing new window
  let l:tab_nr = tabpagenr('$')
  let l:cur_buf = bufnr('%')
  if tabpagenr() < tab_nr
    close!
    if l:tab_nr == tabpagenr('$')
      tabnext
    endif
    sp
  else
    close!
    tabnew
  endif
  "opening current buffer in new window
  exe "b".l:cur_buf
endfunc

这篇关于移动相邻的选项卡以拆分?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆