Sublime Forum

Open sublimetext in split view from terminal

#1

I am trying to open two files side by side with SublimeText from the terminal but it seems there is no way in doing so.

Does anyone have an idea on how to achieve this?

0 Likes

#2

One way to do something like this would be the following (with a caveat, see below):

subl -n left_file right_file --command "new_pane"

That tells subl to get Sublime to create a new window and open the two files inside of it, followed by executing the command new_pane, which will move the currently focused file (which is right_file) into a new pane.

The caveat here is that subl passes instructions to a running instance of Sublime or starts Sublime if it’s not already running; in this latter case subl will launch Sublime and then pass the instructions along.

If Sublime is already running, then this will work as expected. However if subl has to start Sublime running, then the --command will do nothing because the instruction to run the command is delivered before the plugin host has started up.

As far as I’m aware there’s not really a good way around that other than something like having a shell script/batch file that can detect if Sublime is running and impose a delay after starting it before it issues the --command portion.

0 Likes