Using Tabbed Interface in Vim
Give Vim and IDE touch by using tabs to open multiple files. Yes, the same tab experience you have in a web browser or a regular text editor.

Think of Vim tabs like browser tabs for your code editor - each tab holds one or more windows, letting you organize multiple files into logical workspaces.
Unlike window splits that divide your screen, tabs stack contexts you can flip between instantly.

Let's see how you can use tabs in Vim.
Essential Vim tab commands at a glance
Here are the most common actions you can use while dealing with tabs in Vim.
Command | Action | Memory Hook |
---|---|---|
vim -p file1 file2 |
Opens files in tabs | Vim in pages |
:tabnew filename |
Open file in new tab | Tab new |
:tabedit filename |
Open file for editing in new tab | Tab edit |
gt |
Next tab | Go to next |
gT |
Previous tab | Go to previous |
{n}gt |
Jump to tab number n | Go to specific |
:tabfirst |
Jump to first tab | Self-explanatory |
:tabclast |
Jump to last tab | Self-explanatory |
:tabclose |
Close current tab | Self-explanatory |
:tabonly |
Close all other tabs | Keep only this |
:tabs |
List all tabs | Show tabs |
Interesting, right? Let's see it in details.
Opening files in tabs in Vim
Let's start by opening files in tabs first.
Start Vim with multiple files opened in tabs
Launch Vim with multiple tabs instantly:
vim -p file1.py file2.py file3.py
Open two existing files in tabs while starting Vim
How can you open just one file in tab? Well... if it's one file, what's the point of tab, right?
Open a file in a new tab in the current Vim session
When you are already inside Vim and want to open a file in a new tab, switch to normal mode by pressing Esc key and use the command:
:tabnew filename
This will load the file in a new tab. If the file doesn't exist, it will create a new one.
Filename is optional. If you don't provide it, it will open a new file without any name:
:tabnew
Opening existing or new files in tabs from existing Vim session
tabedit
instead of tabnew
, it open the file in Edit mode (insert mode) in the new tab.Search for files and open them in tabs
Search the current directory for filename matching the given pattern and open it in a new tab:
:tabf filename*
This only works if the search results into a single file. If there are more than one file matched, it will throw an error:
E77: Too many file names

tabpagemax
in your vimrc
to something like set tabpagemax=12
Navigating between tabs
You can move between opened tabs using:
:tabn
: for next tab:tabp
: for previous tab
Typing the commands could be tedious, so you can use the following key combinations in the nomral mode:
- gt: To go to the next tab
- gT (i.e. press g and shift and t keys together) To go to the previous tab
If there are too many tabs opened, you can use:
:tabfirst
: Jump to first tab:tablast
: Jump to last tab
In many distributions these days, Vim is preconfigured to show the tab labels on the top. If that's not the case, add this to your vimrc
:
set showtabline=2
You can list all the opened tabs with:
:tabs

:tabm N
. This tabm
is short for tabmove
. Note that Vim starts numbering at 0.Closing tabs
How do you close a tab? If the tab has a single filed opened, the regular save/exit Vim commands work.
But it will be an issue if you have multiple split windows opened in a tab.
:tabclose
: Close current tab:tabonly
: Only keep the current tab opened, close all others
Tab closing operation in Vim
:tabnew | u
creates a new tab and undoes in one motion - your file returns.Bulk tab operations
With :tabdo
command, you can run the same operations in all the tabs.
For example, :tabdo w
will save file changes in all tabs, :tabdo normal! gg=G
auto-indents every file.
Similarly, tabdo %s/oldvar/newvar/g
executes search-replace across every tab simultaneously. Parallel processing for repetitive changes.
You get the idea. tabdo
is the key here.
:mksession project.vim
then vim -S project.vim
restores exact tab layout.Conclusion
While it is good to enjoy tabs in Vim, don't create dozens of them - they become harder to navigate than helpful. Use buffers for file switching and tabs for context switching.
As you can see, with the tab feature, you get one inch closer to having the IDE like experience in Vim.
Creator of Linux Handbook and It's FOSS. An ardent Linux user who has new-found love for self-hosting, homelabs and local AI.