Tabbing in vim

vim is one of the tools one can use for years and still discover new features or better ways to accomplish something. One of these features are tabs, which I didn't know exist until today. Although splitting windows is fine for most tasks, sometimes I wish to edit multiple files in short succession, like some configuration files. In this case, just using vim file1 file2 ... filen does not work as expected, since after one is finished with the first file and tries to close it wit :x or :wq, vim shows up an error E173: n-1 more files to edit and when hitting :x again, it just closes all remaining files. Of course one could use use :bn or similar to navigate to the next file, however, I wish for a way that leaves vim open and only closes the currently displayed file.

The solution to this problem is vim -p file1 file2 ... filen, which opens up all files and when closing the first file, vim stays open and displays the next file. I noticed that vim displays the remaining filenames at the top of the screen, much like tabs in a browser and as it turns out, these are indeed tabs. One can navigate to the next tab with gt and to the previous tab with gT, and even jump to a specific tab by prefixing gt with a number, where the leftmost tab corresponds to the number 1, the one right next to it to 2, et cetera. vim shows only a limited number of tabs, this value can however be modified by setting tabpagemax to a higher value in one's .vimrc; this doesn't seem to be applied unless vim is restarted, though. Also we can force vim to show the tab bar at all times by setting showtabline=2 or disable it regardless of whether tabs are open or not by showtabline=0. Furthermore, one can open new tabs via :tabnew [file] respective :tabf[ind] file. What's especially great is that one can still use horizontal and vertical splits individually in each tab.

Although I'm using vim for years now, I'm always in a way surprised how feature rich this seemingly simple text editor is and I have yet to encounter an editing problem which vim can't solve in a satisfying manner. The help pages would probably be an interesting lecture, but once one can beat most tasks to death fairly efficiently with the features one already knows and only seldom stumbles upon some problems, it should be an acceptable loss if one doesn't read it entirely.