How to work with tabs in Vim

[ Tabs open in Vim and GVim on Windows. ]

Like all modern code editors, Vim has support for tabs since version 7.0. Not only are tabs supported in the GVim (the GUI version of Vim), but they are also fully supported in the console Vim!

Tabs are just the latest in a long history of means for editing multiple files in Vi or Vim. First came buffers, of which only one could be seen on the editor display at a time. Then came windows, which allowed the user to split the editor display into multiple panes, each capable of displaying a different file. And now tabs, each tab of which can be split into multiple windows.

Here are the basic tab commands to get started:

  • :tabedit (or :tabe for short) to open a new empty tab.
  • :tabedit Foo.c (or :tabe Foo.c) to open the file Foo.c in a new tab.
  • :tabnext (or :tabn for short) to switch to the next tab. An easier alternative for this command is gt (remember it as Goto next Tab).
  • :tabclose (or :tabc for short) to close the tab. Since I usually have only window open in a tab, I find it easier to close a tab using the good old :q

Tried with: Vim 7.3


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.