28 August 2021

Using Tabs in Vim

 Using tab in vim

 

https://www.linux.com/training-tutorials/vim-tips-using-tabs/

 

 1. Open a new tab for authoring a new text file

:tabnew

2. Open an existing file in a new tab


:tabf *abc

or

:tabf abc*

or

:tabf abc[tab]

f means find. Suppose that there is a file whose name is abcdef.txt. You type 'abc', then press the Tab key, system will automatically type in the rest of the file name for you.

3. Go to different tabs

gt - to the next tab.
gT - move to the previous tab.
g0 - move to the first tab.
g$ - move to the last tab.

ngt

n: 1 - the first tab; 2 - the second tab, and so on.

4. Moving a tab

:tabm n

n: 0 - the first tab; 1 - the second tab, and so on.

5. Running commands in all the opened tabs

e.g. if we want to substitute 'bar' for 'foo' in all the opened tabs, then

:tabdo %s/foo/bar/gc

5. To see a list of the files opened in all the tabs

:tabs


No comments:

Post a Comment