7

The question in short: Is it possible to open a tab in a window and not a window in a tab?. Like this:

vim the tabs in the windows

Instead of this:

vim the windows in the tabs, the windows visible vim the windows in the tabs, the windows hidden

Some background related to the question:

I'm used to the interface like the one on the first screen shot above, where the tabs are in the windows.

Initially I was able to achieve this in Vim with the help of a console app's functionality, because I was very new to Vim and didn't want to remember even more commands to work with windows. But this approach has some inconveniences to me:

  • no sharing of registers
  • the .viminfo file is opened separately for each instance of vim, and therefore some important information can be lost, if the instance of vim, where it was present was closed first (because each instance of the editor overwrites the .viminfo file).

I've managed some workarounds for each of these problems, listed below in case anyone other will face this issue:

  • for the sharing of registers between windows of a terminal, I installed the xclip application and copy registers with ex-commands like: call system('xclip', @")
  • for the .viminfo rewrite issues I just try to pay attention to the order of closing Vim instances.

But the other day I got tired of this, and decided to try the windows in Vim, and the first thing I found was that the tabs are sort of "above" the windows, what I personally do not like.

I looked some Vim docs about this, and it seems that it is not possible to open a tab in a window. Can anyone answer to this by either explaining how it is possible, or affirming that it is not possible?

  • What benefits exactly are you hoping to gain by having the tabs within the windows? I ask because it's quite possible you should be looking more closely at buffers, rather than tabs. – 8bittree Jan 23 '17 at 16:08
  • @8bittree Thank you, I have already reached this conclusion, as I revisited the "Practical Vim" book by Drew Nile. In Vim the tabs are more like 'virtual desktops' instead of ones from other GUI applications. – user907860 Jan 23 '17 at 16:14
11

From :h tab-page-intro:

A tab page holds one or more windows. You can easily switch between tab pages, so that you have several collections of windows to work on different things.

Usually you will see a list of labels at the top of the Vim window, one for each tab page.

Tabs containing windows is the way Vim was designed to work. I think you should get used to this workflow because trying to use Vim in a different way will introduce more problems than it solves.

7

No you can't, here's why:

Vim use multiple concepts to handle text files:

  • Buffer: An in-memory version of a file. Editing a file will in fact edit the buffer before writing (i.e. saving) anything to the file on your filesystem.

  • Window: A view into a buffer, a representation of the buffer content. A window can switch buffer and split to display multiple buffer at the same time. You can display the same buffer in different window, but a window can only display one buffer at a time.

  • Tab: A collection of windows, and their display on the screen. This is the layout of windows that you currently have.

In the Vim world, tabs contains windows, not the other way around.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.