Using Tabs in Vim
Vim is a powerful text editor with tons of features. However, not all of these features are immediately apparent to new users of Vim. To get started with Vim, check out my Beginner's Guide to Vim. Here's a tip for something I didn't cover in that guide, using tabs in Vim.
To use tabs with Vim, open a file in Vim, like so:
Enter that command in a terminal and Vim will open "mytestfile" and allow you to edit it. To get another tab open in that same instance of Vim, use this command from normal mode (hit Esc to make sure you're in normal mode):
That will open an unnamed document in a new tab. You can see the tabs at the top of your Vim screen. To open a specific file in a new tab, you can do something like:
That will open "myspecificfile" from the same directory as "mytestfile", you're current directory, in a new tab. Say you want to open a file from a different directory or folder, you do this, while in normal mode:
This will open "myotherfile" in the directory "adifferentdir" in your home folder (/home/youruser).
You can move to the next tab you have open by pressing "gt" in normal mode. You can move 2 tabs down by pressing "2gt".
Moving to the previous tab is not too cool in Vim, by default:
So I mapped a key combo for normal mode to move to the previous tab by pressing "gr". You can check out how I did that in my Normal Mode Shortcuts in Vim post.