📜 ⬆️ ⬇️

Tabs

Open up


Vim tabs
You can open a tab in three different ways, the easiest and most intuitive :tabnew in normal mode, it will open a new tab with an empty buffer. You can immediately open the tab with the file by passing its name as an argument

:tabnew futuri.co

Tabs can also be opened immediately after launch, if you add the -p in front of the list of file names — each has its own tab.

vim -p habra.sh habr.py

Of course, to open tabs to infinity does not work, the default is a limit of 10 tabs. It is set by the parameter tabpagemax , for example:
')
:set tabpagemax=15

The restriction only works for opening tabs with the -p . And if you are going to open more tabs than allowed, the files will open, but the tabs will not be displayed and you can navigate through them using the commands :next and :prev .

And one more way to open a tab :tabf . A template is passed as a parameter to it, and if a file is found, it will open in a new tab. For example:

:tabf index*

If the pattern matches more than one file, then vim will simply curse and do nothing. A useful feature :tabf is that it works with <tab> autocompletion.

Move


You can switch to tabs with the commands :tabn and :tabp , for the next and previous tab, or in the normal mode gt and gT respectively, and you can use 5gT , etc.

When there are many tabs open, the :tabfirst commands can be useful :tabfirst or :tabfir open the first tab and :tablast open the last one.

By default, a tab bar is shown only when at least one tab is open, you can enable the permanent display using:

:set showtabline=2

You can view all open tabs using :tabs .

Of course, all these commands can be assigned their own shortcut keys, I use the following:

nmap ,t :tabnew<CR>

Moving


You can move the tabs with the command :tabm n , where n is the position number to which we want to move it, of course, according to the rules of good tone, the numbering of the tabs starts from 0.

:tabm 2

By the way, the use of tabs does not limit other possibilities of the Wim, so no one forbids dividing one tab into several scopes, for example ( :sp :vsp ).

Commanding


You can execute commands on the contents of all tabs using :tabdo command , for example, you can change the name of a variable everywhere:

:tabdo %s///g

Spying


: tabnew [filename]Open new tab
: tabf pat * ernOpen tab by template
: tabsList of open tabs
gt or: tabnNext tab
gT or: tabpPrevious tab
: tabfirst or: tabfirFirst tab
: tablastLast tab
: tabm nMove tab to n (from 0)
: tabdo commandRun on all tabs

And if that's not enough :help tab-page-intro

Source: https://habr.com/ru/post/102373/


All Articles