vim-logoUsing Tabs (vim calls them tab pages) is one of the sure ways to increase your productivity. Vim Tabs are just like the tabs in your browsers. Each tab can have multiple splits (referred as windows in Vim's documentation). So, you can have multiple splits open in one tab and then you can have multiple tabs.

Tabs are a really handy way of grouping things together. So, I usually have multiple tabs open in any session. I have a main editor tab where i will have multiple splits open for the code I am looking at and since I work with a lot of data files, I will have one tab dedicated for the data-sets that I will be using for my program. And, then if required, I will have another tab open for any notes, info that I have previously noted down.

Here are some commands and tips for working with tabs
To create a new tab - :tabnew
To go to the next tab - :tabnext
To go to the previous tab - :tabprevious
I don't like to type all of these commands everytime and so I have added these mappings in my vimrc to make switching between tabs much easier.

nnoremap <C-Tab> :tabnext<CR>
nnoremap <C-S-Tab> :tabprevious<CR>

With these I can move around the tabs just like I do with the tabs in my browser.
Another important thing that you might want to do with tabs is to be able to move them. I am really particular about how my tabs should be ordered and so I have added these mappings to move them around.

nnoremap <silent> <A-Left> :execute 'silent! tabmove ' . (tabpagenr()-2)<CR>
nnoremap <silent> <A-Right> :execute 'silent! tabmove ' . tabpagenr()<CR>

With these you can hit Alt + Left arrow to move it to left and vice versa.
Try  :help tabpage in your Vim help for more info.
A lot of Vim users see tabs as an alternative to buffers and there are a lot of articles, discussions about Buffers Vs. Tabs. But,for me tabs and buffers are not exclusive. I often have multiple tabs opened and will still use buffers when I need them.
So, that is all for this article. Come back again for the next article.
Until then, Happy Vimming.


Image Credits : https://pbs.twimg.com/profile_images/64545277/vim_logo_400x400.png

PS: To see all the vim tutorials of FreBlogg , see : Freblogg/Vim



Published

Category

Software

Tags