1

I'm looking for something like

:tabsplit file1 file2

which will open the two files in a new tab that is split with file1 in one split and file2 in another split

I really want something like tabvsplit. Currently, I am using

:tabe file1
:vsp file2

not too bad, but could be better, and I am wondering if there is something built-in that is easier to type and faster.

2

You can do something like this:

:tabedit +sp\ file1 file2

You can create a new command for that, but that will make the quoting ugly. Something like this might work (warning, this is really ugly, but seems to work from my basic tests):

com! -nargs=+ -complete=file Tabsplit :let a=split(<q-args>) | if len(a) == 2 | exe ':tabedit +'. fnameescape('sp '. a[0]) fnameescape(a[1]) | else | echoerr "too many arguments" |endif

It basically checks, that the supplied arguments are exactly 2 and if that is the case, runs the :tabedit +sp command mentioned earlier and if not, will echo an error message.

I am not quite sure, the fnameescape() is needed for the file arguments. You need to test, if this is really required when using a filename that contains spaces.

  • eyes widen woah (to the second one). Thanks for the first tip. I'll check out second one after work. – dylnmc Jun 28 '17 at 19:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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