detfalskested

Open tabs at specific positions in Vim

I've been using Vim for ages. So it's almost a bit embarrassing that I didn't know this already and initially created this as a user command, until I read the help entry for :tabnew.

I felt I needed to be able to open a new tab before the current tab, instead of always opening it after. Small thing, but useful. So I created a user command that would basically do :tabnew <filename> and :tabm -1 for me at once. And then, of course, I suddenly felt the need to be able to position the new tab anywhere!

Fortunately, I then read the help pages. And there it already was, in all its glory:

:[count]tabnew
                Open a new tab page with an empty window, after the current
                tab page.  If [count] is given the new tab page appears after
                the tab page [count] otherwise the new tab page will appear
                after the current one.
                    :tabnew     " opens tabpage after the current one
                    :.tabnew    " as above
                    :+tabnew    " opens tabpage after the next tab page
                                " note: it is one further than :tabnew
                    :-tabnew    " opens tabpage before the current one
                    :0tabnew    " opens tabpage before the first one
                    :$tabnew    " opens tabpage after the last one

Lovely!