Scroll back to the top

Tabs in Vim editor

[ vim linux ]

It doesn’t need to explain the role of Vi/Vim text editor in our life. I tend to call it default console editor, or even just default text editor. Usually, I use buffers or cool window manager provided by the plugin to switch virtual screen, when I edit several files in Vim. But today I found for myself regular built-in Tabs feature provided in my current Vim version out of the box. It’s like in other text editors/IDE’s. So, I don’t need all those buffers, etc., as there are tabs.

For records:

When starting Vim, the
option opens each specified file in a separate tab

vim -p first.txt second.txt

:tabe file    open file in new tab
:tabc         close tab
:tabc {i}
:tabonly      class all other tabs

gt            go to next tab
gT            go to previous tab
{i}gt         go to tab in position i

# do something through all the
:tabdo %s/foo/bar/g

:tabs         list all tabs including their displayed windows
:tabm 0       move current tab to first
:tabm         move current tab to last
:tabm {i}     move current tab to position i+1

:tabn         go to next tab
:tabp         go to previous tab
:tabfirst     go to first tab
:tablast      go to last tab

:tab ball         show each buffer in a tab (up to 'tabpagemax' tabs)
:tab help         open a new help window in its own tab page
:tab drop {file}  open {file} in a new tab, or jump to a window/tab containing the file if there is one
:tab split        copy the current window to a new tab of its own


set showtabline=2
imap ,t <Esc>:tabnew<CR>

Happy editing!