Sublime Forum

Opening 2 column layout from plugin

#1

I want to split the current editor view in 2 (like the Columns: 2 layout) and open one file in each side.

Any ideas how to achieve this in a Plugin?

0 Likes

#2

If you look in the default key bindings, you can find the command that splits the screen. Then you’ll need to write a plugin that uses sublime.Window.run_command() to execute the command you found through the key bindings file. sublimetext.com/docs/2/api_reference.html has details about the API. Taking a look at some existing plugins can always be of help to figure out how things work. The ones in the Default package tend to be fairly simple.

If you want more of a walk through, I wrote an article a while ago that talks about some of the details. net.tutsplus.com/tutorials/pytho … -2-plugin/

0 Likes

#3

wbond,

Thank you!

I have this plugin started already, and will add the slipt window now:

github.com/webbynode/GoToSpec

Best,

– Felipe.

0 Likes

#4

OK, I got as far as to open two columns:

		self.window.run_command('set_layout', 
			{ "cols": [0.0, 0.5, 1.0], "rows": [0.0, 1.0], "cells": [0,0,1,1],[1,0,2,1]] })

However, how can I open a file on an active group? I managed to do this:

		self.window.focus_group(1)

To select the right-side editor, but when I run open_file, it opens on the left.

Any ideas?

Thanks,

– Felipe

0 Likes

#5

Ok, I figured this one out.

Here’s a video of my GoToSpec plugin in action:

I will make a separate post to announce it.

0 Likes