In Part 1 and Part 2 we learnt about buffers and Windows respectively In this blog we will learn about Tabs and how to navigate among Tabs
Here is a recap of the terms buffers, windows, and tabs.
- A buffer is the in-memory text of the file that was opened using vim. It may be visible or hidden. It is identified by a buffer number and has flags to indicate whether it is current, has been modified or not etc.
- A window is a viewport on a buffer whereas
- A tab is a collection of windows
Lets open 3 files using VIM
vim -O file1 file2 file3
-O causes vim to open 3 vertically split windows each one showing a view of the file1, file2, file3 respectively
The cursor is in the window named file1, now hit
CTRL-W T to convert the current window to one Tab and the balance windows to another Tab.
The Tab name on the screen is same as the current filename for that tab. In case the Tab has more than one window the the tab name follow a number indicating the the number of windows in that Tab
Moving from one Tab to another is as easy as issuing one of the following commands
:tabnext :tabprev :tabfirst :tablast Go ahead and try these out.
Note: It is possible to view/edit the same file in all tabs – unlike other editors, vim is not limited by one Tab per file constraint.