Methuz Kaewsai-kao
Methuz Kaewsai-kao

Reputation: 1276

Switching from tab to splitted window in vi/vim?

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.

Upvotes: 3

Views: 1344

Answers (5)

A117
A117

Reputation: 498

to switch tabs into windows

:sball | tabo

explained below.

to split windows for all buffers

:sball

to close other tabs

:tabo

to split window for a certain buffer

:sb <buffer  number>

Upvotes: 0

jso
jso

Reputation: 21

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)

Upvotes: 2

sehe
sehe

Reputation: 392883

If you

:edit file1
:tabedit file2

and then want to compare them, just

:vert diffsplit file1

Upvotes: 2

Ingo Karkat
Ingo Karkat

Reputation: 172520

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

Upvotes: 4

Xavier T.
Xavier T.

Reputation: 42198

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.

Upvotes: 4

Related Questions