← All lessons

13. Tabpages

Step 2 of 6

Other ways to create new tabpages

:tabnew creates a tab with a new, blank file opened. You can also use :tabedit — much in the same way as you would use :edit — to open a file in a new tab.

But here’s a really useful trick: if you prefix any command that would ordinarily open a new window with the :tab command, it’ll open that window as a new tabpage instead. For instance:

That particular command — :tab sp — is really handy. It lets you “zoom in” on a singular window by opening it in a new tabpage. I use this to “break flow” and wander off somewhere else in a project, safe in the knowledge that I can return to my previous tabpage later.

Let’s try these in the editor. There are a few files on disk, called dog.txt, cat.txt, and mouse.txt. First, try opening them in new tabpages with the :tabedit command. For example: to open cat.txt in a new tabpage, you’ll want to write :tabedit cat.txt.

Once you’re used to the :tabedit command, let’s experiment with :tab sp. In your current tabpage, run :args *.txt followed by :all to open all of the *.txt files in a new split. Then, move your cursor to any of the splits and run :tab sp. You should see the window be “broken out” into its own tabpage!

Loading editor…