Beginners Guide to Tabs in Vim
Beginners Guide to Tabs in Vim Table of contents
Tabs are a very common feature on many IDEs, however when I have seen people use Vim it seems rare for them to use tabs.
Of course Vim has a great tab feature built in (no need to install any Vim plugin), and once you start getting used to its commands you will find that you quickly get the hang of it.
|Open a file in a new tab|
|Close current tab.|
|Close all OTHER tabs (leave ONLY currently selected tab)|
|If current file is part of a split view, then open currently selected split as a new tab|
Moving between tabs is easy!
To move to the next tab:
To move to the previous tab:
If you wanted to move to a certain tab (based on its position - the one on the far left is #1), you do the following command:
#gt - replace # with the number. For example to go to the 3rd tab type
|Move current tab to position #|
|Move current tab to the end|
Here are some useful lines to add to your .vimrc. Some of this is based on the excelent amix/vimrc config, I recommend you check it out on Github.
- #Better tab experience - from https://webdevetc.com/
- map <leader>tn :tabnew<cr>
- map <leader>t<leader> :tabnext
- map <leader>tm :tabmove
- map <leader>tc :tabclose<cr>
- map <leader>to :tabonly<cr>