Step 4 of 6

13. Tabpages

Closing tabpages

You can close a tabpage by:

  • closing all of the windows within it, or
  • using the :tabclose command

If you close all of the windows in a tabpage, the tabpage itself is closed — pretty intuitive.

You can also use the :tabclose command. :tabclose by itself will close the current tabpage, and :[count]tabclose — e.g. :2tabclose — can be used to close a tabpage by its number. One thing to keep in mind: just like :quit, :tabclose refuses to throw away a buffer with unsaved changes.

Try it! Work through the checklist below. Open a labeled tabpage and a blank one, close the blank one with :tabclose — you’ll land on the labeled tabpage beside it — then close the very first tabpage by its number, without even leaving the tabpage you’re standing on.

  1. Create a tabpage labeled two Run :tabnew, then press i, type two, and press Esc.
  2. Create one more tabpage A third tabpage, left blank this time — type :tabnew and hit Enter.
  3. Close the current tabpage The blank tabpage disappears and you land back on two — type :tabclose and hit Enter.
  4. Close the first tabpage by number A count picks the victim from anywhere, closing the first tabpage without leaving this one — type :1tabclose and hit Enter.
Create a tabpage labeled two Run :tabnew, then press i, type two, and press Esc.

Next: Create one more tabpage

Loading editor…