Switching from tab to splitted window in vi/vim?

心已入冬 提交于 2019-12-12 14:42:51

问题


We can make new tab using :tabnew. We can split window using :vs or :sp.

Sometimes I want to switch from tab to splitted window to compare my code or switch back to get more space. Now I do it by closing it then use another command. Is there any easier way?

Thank you.


回答1:


Tabs and splits are different concepts.

A vim "tab" is really a window layout. It means that for example you can have a tab with vertically split windows and another one with horizontally split windows.

It seems you question is when I have split windows, how do I switch back to a full view. You can Ctrlwo to expand the current window to the full tab.

See :help windows.txt to get the full list of commands related to windows management.




回答2:


The easiest way (with built-in means) to move / copy a window from one location to another (split, tab page) within Vim is to use the current window's buffer number (which can be put into the 'statusline', or :ls will tell you), e.g. as in:

:sb[uffer] 3

To open the current window in a separate tab, you can use:

:tab split



回答3:


If you

:edit file1
:tabedit file2

and then want to compare them, just

:vert diffsplit file1



回答4:


switch all buffers to vertical split:

:bufdo vs

switch all buffers to horizontal split:

:bufdo sp

switch all buffers to tab mode:

:bufdo tab split

(use [ctrl]-w o to close all but current window in split mode, :bdel to delete current buffer, :qa to close all / :wqa to save and close all)



来源:https://stackoverflow.com/questions/18978068/switching-from-tab-to-splitted-window-in-vi-vim

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!