Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm wondering, if I have already open two files in Vim with a vertical split, but I want to open another two files in an extra tab and split those two files in vertical window, how can I do it?

I know I can do:

:tabnew file1
:vsp file2

Is there a way to do it one-line?

share|improve this question
up vote 6 down vote accepted

I'm not sure this is what you're looking for, but it is one line:

:tabnew file1 | vsp file2


:help :bar
share|improve this answer

I just found a similar method, using the command-line pipes, but I think it's a lot more powerful:

:tabnew | args views/* | vertical all

This opens a new tab, then loads all the files in the views directory. Instead of passing a glob to args we can specify separate files. vertical splits the pane into separate vertical windows, which is what I prefer. all tells it to use all the files passed by args.

share|improve this answer

When you say "in one line", I suspect you are not just talking about using a vertical bar character | instead of a newline. Rather, I suspect you are looking for a shorter way of performing your task.

You can get what you want by combining the existing suggestions into a user-defined command (see help :command). User-defined commands must start with a capital letter.

For example, if you are a C++ programmer, it may be that you like to open a new tab that has the implementation and header files side-by-side. At that point you can define a command such as this in your .vimrc:

:command -nargs=1 -complete=file Tabv tabe <args>H | vs <args>C

Which can be used thus:

:Tabv Foo

to open Foo.C on the left and Foo.H on the right in a new tab.

If your typical usecase is not this specific, it may be more difficult to save keystrokes. Since you are asking this on SU instead of SO, perhaps you are not a programmer, but hopefully you can adapt this suggestion to fit your needs.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.