Lesson 15 of 26
Tabs as window Layouts
In this lesson
Roy explains that a tab contains windows and each window is a view into a buffer, so the same file can be open in two tabs at once. He argues that tabs are meant as collections of windows used for layout: in one tab he puts the vimrc and a new file side by side with vsplit, adds a third file with split and moves between them with Ctrl-W. He sums up tabs as a way to lay out buffers or to have different views of the same project.
Transcript
[00:08] (external link, opens in new tab) So now that we've seen windows and tabs, let's understand buffers and the fact that tabs are actually not supposed to be used the way you use tabs today in other IDEs. That is a tab basically can contain a window and a window is just one of them and a window is a view into a specific buffer and you can have multiple windows pointing to the same buffer. In this case, I have one tab that has one window that views the buffer of file 2 and I have another tab with one window that has a view to the vimrc file.
[00:41] (external link, opens in new tab) But technically, I can view both files in two different tabs or the same file in two different tabs. All I have to do is to say e, sorry, let's make this focus. e .vimrc. And now I have the same file open in two tabs. So what's the point of tabs really? If I just go to the next tab, I'm just switching between the file. And the answer is that tabs were really supposed to be a collections of windows or basically used for layout.
[01:13] (external link, opens in new tab) So for example, in this case, I can say that in this tab, I'm editing Vimrc side by side with my new file. So I'm going to do a vsplit and file two. So now in this tab I have these two files and I can move between them with control w and and and right or control w and left that is control wtrl w. I can then further split this.
[01:43] (external link, opens in new tab) For example, in this window right now, I can say split with new file. Another third file that I created. So now I have these three files. I can do control W down, control W right, W left. But this is just the layout of these things. I can switch to my previous tab by saying GT go to next tab. And here I have just one of the files. So I have GT here and I have GT here. And these one of them shows the same file.
[02:15] (external link, opens in new tab) It's just different layouts. So tabs are one way to lay out all your buffers or to have different views of the same project.