Tabbed Editing

Did you know that in addition to editing in multiple windows, you can create multiple tabs? Vim lets you create new tabs, each of which behaves independently. In each tab you can split the screen, edit multiple files—virtually anything you would normally do in a single window, but now all of your work is easily managed in one window with tabs.

Many Firefox users are very familiar with and dependent on tabbed browsing and will recognize what this feature brings to power editing. For the uninitiated, it’s worth trying.

You can use tabs in both regular Vim and gvim, but gvim is much nicer and easier. Some of the more important ways to create and manage tabs include:

:tabnew filename

Open a new tab and edit a file (optional). If no file is specified Vim opens a new tab with an empty buffer.

:tabclose

Close the current tab.

:tabonly

Close all other tabs. If other tabs have modified files, they are not removed unless the autowrite option is set, in which case all modified files are written before the other tabs are closed.

In gvim you can activate any tab simply by clicking the tab at the top of the screen. You can also activate tabs in character-based terminals with the mouse if the mouse is configured (see the mouse option). Also, it’s easy to move right and left from tab to tab with CTRL PAGE DOWN (move one tab to the right) and CTRL PAGE UP (move one tab to the left). If you are in the leftmost or rightmost tabs and you try to move left or right respectively, Vim moves to the ...

Get Learning the vi and Vim Editors, 7th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.